Exception "TypeError: child watchers are only available on the default loop" in gevent.subprocess

1,827 views
Skip to first unread message

Giovanni Mascellani

unread,
Jun 5, 2013, 2:47:53 AM6/5/13
to gev...@googlegroups.com
Hi.

I'm testing gevent 1.0rc for my application. In this application I call
gevent.subprocess.call() and receive an exception like this:

> Traceback (most recent call last):
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/service/Worker.py", line 105, in execute_job
> self.task_type.execute_job()
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/TaskType.py", line 250, in execute_job
> return self.compile()
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/tasktypes/Batch.py", line 141, in compile
> sandbox = create_sandbox(self)
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/TaskType.py", line 55, in create_sandbox
> sandbox = Sandbox(task_type.file_cacher)
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/Sandbox.py", line 219, in __init__
> ret = subprocess.call(box_cmd + ["--init"])
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 115, in call
> return Popen(*popenargs, **kwargs).wait()
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 235, in __init__
> errread, errwrite)
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 721, in _execute_child
> self._watcher = self._loop.child(self.pid)
> File "core.pyx", line 490, in gevent.core.loop.child (gevent/gevent.core.c:8044)
> File "core.pyx", line 1736, in gevent.core.child.__init__ (gevent/gevent.core.c:25823)
> TypeError: child watchers are only available on the default loop

I understand that this error comes from the underlying libev, but I
don't understand whether it is to be considered a gevent bug or if I'm
calling gevent.subprocess.call() the wrong way around. In this case,
please, could you tell me what's the proper way? I know close to nothing
about libev and gevent internals.

If instead this is a bug in gevent, I can file it as an issue con GitHub.

I could obtain this bug both with master and with 1.0rc2. Please let me
know if you need more information or tests (actually, the source code
I'm working on is public[1], but I doubt that you want to set it up to
investigate this report).

[1] https://github.com/giomasce/cms/tree/gevent

Thanks for helping.

Giovanni.
--
Giovanni Mascellani <masce...@poisson.phc.unipi.it>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.masc...@jabber.org / giov...@elabor.homelinux.org



--
Giovanni Mascellani <masce...@poisson.phc.unipi.it>
Pisa, Italy

Web: http://poisson.phc.unipi.it/~mascellani
Jabber: g.masc...@jabber.org / giov...@elabor.homelinux.org

signature.asc

Giovanni Mascellani

unread,
Jun 5, 2013, 4:42:10 PM6/5/13
to gev...@googlegroups.com
Il 05/06/2013 08:47, Giovanni Mascellani ha scritto:
> I understand that this error comes from the underlying libev, but I
> don't understand whether it is to be considered a gevent bug or if I'm
> calling gevent.subprocess.call() the wrong way around. In this case,
> please, could you tell me what's the proper way? I know close to nothing
> about libev and gevent internals.

My bad, I just realized that the call to gevent.subprocess was performed
in a different thread than the one supporting the libev cycle. This is
perfectly justified in not working, although the error message could be
somewhat clearer.

Sorry for the fuss and thanks for gevent!
signature.asc

Giovanni Mascellani

unread,
Jun 4, 2013, 5:59:43 PM6/4/13
to gev...@googlegroups.com
Hi.

I'm testing gevent 1.0rc for my application. In this application I call
gevent.subprocess.call() and receive an exception like this:

> Traceback (most recent call last):
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/service/Worker.py", line 105, in execute_job
> self.task_type.execute_job()
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/TaskType.py", line 250, in execute_job
> return self.compile()
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/tasktypes/Batch.py", line 141, in compile
> sandbox = create_sandbox(self)
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/TaskType.py", line 55, in create_sandbox
> sandbox = Sandbox(task_type.file_cacher)
> File "/usr/local/lib/python2.7/dist-packages/cms-1.1.0pre-py2.7.egg/cms/grading/Sandbox.py", line 219, in __init__
> ret = subprocess.call(box_cmd + ["--init"])
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 115, in call
> return Popen(*popenargs, **kwargs).wait()
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 235, in __init__
> errread, errwrite)
> File "/usr/local/lib/python2.7/dist-packages/gevent-1.0dev-py2.7-linux-x86_64.egg/gevent/subprocess.py", line 721, in _execute_child
> self._watcher = self._loop.child(self.pid)
> File "core.pyx", line 490, in gevent.core.loop.child (gevent/gevent.core.c:8044)
> File "core.pyx", line 1736, in gevent.core.child.__init__ (gevent/gevent.core.c:25823)
> TypeError: child watchers are only available on the default loop

I understand that this error comes from the underlying libev, but I
don't understand whether it is to be considered a gevent bug or if I'm
calling gevent.subprocess.call() the wrong way around. In this case,
please, could you tell me what's the proper way? I know close to nothing
about libev and gevent internals.

If instead this is a bug in gevent, I can file it as an issue con GitHub.

I could obtain this bug both with master and with 1.0rc2. Please let me
know if you need more information or tests (actually, the source code
I'm working on is public[1], but I doubt that you want to set it up to
investigate this report).

[1] https://github.com/giomasce/cms/tree/gevent

Thanks for helping.

signature.asc
0 new messages