On 18/05/2010 13:10, Graeme Glass wrote:
On Tue, May 18, 2010 at 9:22 AM, pacopyc<paco...@gmail.com>  wrote:
Hi, I've a question for you. I'd like to call a function and waiting its
return value for a time max (30 sec).
The function could not respond and then I must avoid to wait for infinite
time.
Can you help me?

Thanks
It depends on what method you are calling? From what module?
Some methods, take a timeout parameter (aka socket).

You could call your method in a thread and a timeout on the thread.
http://docs.python.org/library/threading.html#module-threading

This very much depends on what you trying to do, as to what is the
best way to go.

Maybe you could give a little bit more information about what you are
trying to achieve and what modules/methods you trying to access.
Since you posted to win32 mailing list, I am assuming you are running
this windows.

hth.

Graeme
Ok, you're right. I'm developing a software to monitor my LAN (Windows clients). I'm using WMI and pywin32 (win32net.NetLocalGroupMembers, win32net.NetGroupEnum,Win32_NetworkAdapterConfiguration, .....). Maybe that a Windows client not respond (blocked, personal firewall, ...) and then my script wait for an infinite time. Of course this is no good. If function respond with an error my script catch it, but if function don't finish is a big problem. That is why I'd like finish the function and analyse next client. I think that I must set a max time.
Thank you very much.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to