async interface

79 views
Skip to first unread message

Amir Rossert

unread,
Feb 6, 2021, 10:52:25 AM2/6/21
to psutil
Is there any plans to introduce async interface to the Process class? 
In my use case I have multiple processes that I monitor and I want to "wait" for each process using the "wait()" method, currently it is blocking call so in order to do this I need to use "run_in_executor" which spawn a thread for each process.

Is there any other way of doing so without threads? 

Giampaolo Rodola'

unread,
Feb 6, 2021, 1:04:36 PM2/6/21
to psutil
Both psutil.Process.wait() and psutil.wait_procs() can be passed timeout=0 and will act in a non-blocking fashion.

Amir Rossert

unread,
Feb 7, 2021, 4:48:51 AM2/7/21
to psu...@googlegroups.com
Thanks, I know that but I'm wondering if we can do it without polling, like:
`await process.wait()`

--
You received this message because you are subscribed to the "Python process utilities (psutil)" project group:
https://groups.google.com/g/psutil
To post to this group, send email to psu...@googlegroups.com
To unsubscribe from this group, send email to psutil-un...@googlegroups.com
---
You received this message because you are subscribed to a topic in the Google Groups "psutil" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/psutil/6N0sHE9dwkU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to psutil+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psutil/ea206f7d-5206-46d8-b05b-711365add9abn%40googlegroups.com.


--
-- 


Amir Rossert, Software Engineer
amir.r...@safebreach.com

+972-50-6792-702

www.safebreach.com

                                                                 

Stop Tomorrow's Breach. Today.

Giampaolo Rodola'

unread,
Feb 7, 2021, 5:03:35 AM2/7/21
to psu...@googlegroups.com
No, you have to build on top of that. You should run that in an async thread / task / coroutine. If you are using asyncio look for “run_in_executor”.


You received this message because you are subscribed to the Google Groups "psutil" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psutil+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psutil/CAPoV5n%2B2%2B2mTwziX_BGzM%2B5BK9zODoOdsK6H5Z34C8c9xEbfNQ%40mail.gmail.com.
--
Giampaolo - gmpy.dev

Reply all
Reply to author
Forward
0 new messages