Well, I'm not sure what you are doing but works perfectly fine for me. It is probably wrong approach but it works. Also sleep works as you can see:
Code
18:54:21.011 T:140349246789376 DEBUG: CPythonInvoker(2, /storage/.kodi/userdata/autoexec.py): start processing
18:54:21.196 T:140349246789376 DEBUG: CPythonInvoker(2, /storage/.kodi/userdata/autoexec.py): the source file to load is "/storage/.kodi/userdata/autoexec.py"
18:54:21.199 T:140349246789376 DEBUG: CPythonInvoker(2, /storage/.kodi/userdata/autoexec.py): setting the Python path to /storage/.kodi/userdata:/usr/share/kodi/addons/script.module.pil/lib:/usr/share/kodi/addons/script.module.pycryptodome/lib:/usr/lib/python27.zip:/usr/lib/python2.7:/usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-old:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/site-packages:/usr/lib/python2.7/site-packages/gtk-2.0
18:54:21.200 T:140349246789376 DEBUG: CPythonInvoker(2, /storage/.kodi/userdata/autoexec.py): entering source directory /storage/.kodi/userdata
18:54:21.444 T:140349246789376 NOTICE: peter before sleep
18:54:26.449 T:140349246789376 NOTICE: peter after sleep
18:54:26.452 T:140349246789376 NOTICE: peter after json
18:54:26.452 T:140349246789376 INFO: CPythonInvoker(2, /storage/.kodi/userdata/autoexec.py): script successfully run
18:54:26.458 T:140349246789376 INFO: Python script stopped
18:54:26.459 T:140349246789376 DEBUG: Thread LanguageInvoker 140349246789376 terminating
18:54:26.459 T:140350134870784 NOTICE: AddOnLog: PVR IPTV Simple Client: peter GetChannelStreamProperties 2 url: telemach.php?channel=slo1-hd
18:54:26.472 T:140350134870784 DEBUG: Loading settings for pvr://channels/tv/All channels/pvr.iptvsimple_323346058.pvr
18:54:26.472 T:140350134870784 DEBUG: CPlayerCoreFactory::GetPlayers(pvr://channels/tv/All channels/pvr.iptvsimple_323346058.pvr)
Display More