|
| Author |
Message |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Sun Mar 18, 2012 1:41 am Post subject: Preventing Windows 7 sleep during transfers |
|
|
If this has been asked and answered 1) I apologize and 2) would appreciate someone pointing me at the answer. I cannot find it.
Is there a way to prevent Windows 7 from going to sleep during a transfer? Being a good green guy (Irish) I have my PS set to go to sleep after 20 minutes of inactivity. Of course, Windows does not recognize a pyTivo transfer as "activity" and the machine goes to sleep. I can wake up the machine remotely (using an app on my Android phone) so I can get the shares to show up (after waiting a few minuted for the beacon to do its job). However, when I start a transfer, it stops in 20 minutes when the PC goes to sleep.
I have found some thoughts on coding to prevent systems from going to sleep (this problem is apparently not unique to pyTivo) but am not smart enough to know how to implement them
Any ideas? |
|
| Back to top |
|
 |
philhu
Joined: 04 Jan 2008 Posts: 474
|
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Mon Mar 19, 2012 1:56 pm Post subject: |
|
|
Thanks. This is definitely a step in the right direction. However, it apparently doesn't work in Windows 7 according to a later post in the same thread http://www.vistax64.com/general-discussion/222308-vista-goes-sleep-while-burning-dvd-2.html#post1229022
I have not verified that it does not work yet, but I have seen other discussions claiming that calls to SetThreadExecutionState don't seem to work as described in Windows 7. Will try this later today.
Given my severely rusty programming skills, I will probably do more damage than I am worth trying this
EDIT: Here is a thread describing the problem with Windows 7. http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/windows-7-sleeps-more-than-the-7-dwarfs/c48d35f1-2604-4404-9b60-bf3c69f42d59
Here is another one with MAYBE a hint of a kinda cure http://answers.microsoft.com/en-us/windows/forum/windows_7-performance/windows-7-enters-standby-while-cscript-is-running/51b8e4ae-28d8-40cc-99b9-d106235da25c
More details ... If the system goes to sleep when there are no transfers, I understand that the Shares will disappear from my Tivo. I use an Android app on my phone to send a Wake Up on LAN command to the PC and a few moments later, the shares are there, which is acceptable. Then, if I start a transfer, 20 minutes later, the server goes to sleep and the transfer crashes.
Any help would be much appreciated. |
|
| Back to top |
|
 |
philhu
Joined: 04 Jan 2008 Posts: 474
|
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Wed Mar 21, 2012 12:56 am Post subject: |
|
|
Thanks for the suggestion. I already have this app. It works fine for those situations where I am at the PC when I initiate the task. However, what I really need is something that will trigger when I start a transfer remotely i.e. a pull from the tivo end. I am going to try to figure out how this thing works and perhaps build a version that I can call from pytivo. Any additional suggestions from anyone will be appreciated.
EDIT: FWIW, here is another approach to solving the problem. This moves the mouse 1 pixel back and forth every 30 seconds or so and uses that to keep things awake.
http://www.symantec.com/connect/downloads/readynosleepexe-prevents-screensaver-and-pc-locking |
|
| Back to top |
|
 |
philhu
Joined: 04 Jan 2008 Posts: 474
|
Posted: Thu Mar 22, 2012 1:01 pm Post subject: |
|
|
| cant you modify pytivo so it calls this app to keep awake at the start of the transfer? |
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
|
| Back to top |
|
 |
lucasnz
Joined: 13 Sep 2010 Posts: 251
|
Posted: Thu Mar 22, 2012 7:37 pm Post subject: |
|
|
I'd be interested in including this functionality in my fork of pytivo. The difficulty is, while pytivo knows when the transfer starts, it doesn't really know when they are complete. Perhaps delaying sleep by 5 minutes each time data is transferred would work? Alternatively there is a clean up function that clears off failed transfers.
This article describes how to call win32 functions in python:
http://docs.python.org/library/ctypes.html
If you figure can figure out the correct commands to delay sleep for 5 mins then (or to stop sleep), then I can assist in integrating it into pytivo.
Luke |
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Thu Mar 22, 2012 11:23 pm Post subject: |
|
|
Cool! This sounds like a good project to keep me out of the bars this weekend I will take a run at it. |
|
| Back to top |
|
 |
Iluvatar
Joined: 29 Feb 2008 Posts: 335
|
Posted: Fri Mar 23, 2012 12:45 am Post subject: |
|
|
| lucasnz wrote: | I'd be interested in including this functionality in my fork of pytivo. The difficulty is, while pytivo knows when the transfer starts, it doesn't really know when they are complete. Perhaps delaying sleep by 5 minutes each time data is transferred would work? Alternatively there is a clean up function that clears off failed transfers.
This article describes how to call win32 functions in python:
http://docs.python.org/library/ctypes.html
If you figure can figure out the correct commands to delay sleep for 5 mins then (or to stop sleep), then I can assist in integrating it into pytivo.
Luke |
Not sure on *nix yet but the consensus on Win is with 'SetThreadExecutionState'
Example from SABnzbd:
| Code: |
def keep_awake():
""" If we still have work to do, keep Windows system awake
"""
global KERNEL32
if KERNEL32 and not sabnzbd.downloader.Downloader.do.paused:
if (not PostProcessor.do.empty()) or not NzbQueue.do.is_empty():
# set ES_SYSTEM_REQUIRED
KERNEL32.SetThreadExecutionState(ctypes.c_int(0x00000001))
|
_________________ My pyTivo fork - Read link for changes
FFmpeg for OS X |
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Fri Mar 23, 2012 1:12 am Post subject: |
|
|
Specifically on Win prior to Win 7, SetThreadExecutionState( ES_CONTINUOUS | ES_SYSTEM_REQUIRED )
However, I have stumbled across enough stuff now saying this does not work as advertised i.e. does not work in Win7 in the same way it worked in Vista and XP (don't know why as yet but trying to figure it out) and, worse yet, other programs running concurrently (for whatever reason) can turn this thing off (for example, scheduled virus scan). FWIW, Microsoft for Win7 is pushing Power Availability Requests per this Microsoft white paper http://www.microsoft.com/whdc/system/pnppwr/powermgmt/AvailabilityRequests.mspx
Still don't know exactly what this all means. I suppose worst case it means one version for Win7 and another for prior WIN (ugh).
I guess I opened a small can of ugly little worms here
Thanks for flogging this issue. I really appreciate it. |
|
| Back to top |
|
 |
lucasnz
Joined: 13 Sep 2010 Posts: 251
|
Posted: Fri Mar 23, 2012 2:30 am Post subject: |
|
|
| I don't see any reason to support pre win7 for this feature... |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 2009 Location: Maryland
|
Posted: Fri Mar 23, 2012 3:38 am Post subject: |
|
|
You're using pyTivo intermittently -- why not stop it and start it when you need it, instead of treating it as a full-time service, but having to manually wake the server each time? That would eliminate the delay you're seeing, since pyTivo is recognized immediately when it first starts up. And you could wrap pyTivo as a whole in your sleep-defeater, if necessary.
The idea that it's OK for shares to disappear while pyTivo is running (but not for transfers to be interrupted), and that we should design for that, is not one that I can embrace. _________________ My pyTivo fork . My page |
|
| Back to top |
|
 |
stevehogan
Joined: 18 Mar 2012 Posts: 7
|
Posted: Fri Mar 23, 2012 4:43 am Post subject: |
|
|
No, It is not that I am actually using it intermittently; I just want to save a few kw of electricity and not have to haul my fat butt up the stairs and start pytivo just to transfer a movie. The way I would like to use this is to start it up remotely (using wake up on LAN from my Android phone) then transfer a file from the library. Perhaps this does not meet your vision of how this should work and for that I truly apologize. I do truly do appreciate the work you have done creating this and I do apologize if I have in some manner offended you or anyone else. Not everyone in this world does everything the same way. FWIW, (per lucansz) I see no reason to support pre WIN7 either inasmuch as those versions of Windows are dying a well-deserved death. Thanks to everyone who has contributed to this effort thus far. If a solution becomes available, I would appreciate seeing it. If I am able to flog through this and develop one myself, I will be delighted to share it with everyone who is interested. The next step in this process will be for me to figure out how to cause a Wake up on Lan based upon a packet being received from a specific IP (my Tivo, which has a fixed IP) so that perhaps I can force the Tivo to cause the PC to wake up (perhaps this is impossible).
Just so you know, my incentive for this was having an unattended PC (my previous pytivo source running 24 hours a day) have a failure that blew a physical hole in the motherboard and costing me about two weeks of recovery work. I have thus promised myself to do whatever I can to minimize the stress on my system going forward. Hence this request. Respectfully submitted. |
|
| Back to top |
|
 |
wmcbrine

Joined: 04 Jan 2008 Posts: 2009 Location: Maryland
|
Posted: Fri Mar 23, 2012 5:58 am Post subject: |
|
|
I don't know why you'd think I was offended. All I'm saying is, no. For me, anyway.
There's no reason that starting pyTivo should require a physical trip, BTW. Even Windows has an optional telnet service, or of course you can do the remote framebuffer thing. _________________ My pyTivo fork . My page |
|
| Back to top |
|
 |
|