issues with gevent win32com and AutoItX

35 views
Skip to first unread message

Bruno Bigras

unread,
Jan 17, 2012, 10:12:48 AM1/17/12
to gevent: coroutine-based Python network library
Hi,

If I run the following code, I only see "task2 started". It runs fine
without the "WinWaitActive" lines.

I guess win32com or AutoItX may not work with gevent. I wonder if I
should use a thread instead.

Any ideas?

Thanks,

Bruno

-
import gevent
import win32com.client


def task1():
print "task1 started"
auto = win32com.client.Dispatch("AutoItX3.Control")
auto.WinWaitActive("test1.txt - Notepad")


def task2():
print "task2 started"
auto = win32com.client.Dispatch("AutoItX3.Control")
auto.WinWaitActive("test2.txt - Notepad")


threads = []
threads.append(gevent.spawn(task1))
threads.append(gevent.spawn(task2))
gevent.joinall(threads)

Denis Bilenko

unread,
Jan 23, 2012, 2:35:54 AM1/23/12
to gev...@googlegroups.com
On Tue, Jan 17, 2012 at 10:12 PM, Bruno Bigras <bigras...@gmail.com> wrote:
> If I run the following code, I only see "task2 started". It runs fine
> without the "WinWaitActive" lines.
>
> I guess win32com or AutoItX may not work with gevent. I wonder if I
> should use a thread instead.

Yes, try the thread pool.

Instead of

auto.WinWaitActive("test2.txt - Notepad")

do

gevent.get_hub().threadpool.apply(auto.WinWaitActive, "test2.txt - Notepad")

Note, that WinWaitActive must be thread-safe.

Reply all
Reply to author
Forward
0 new messages