Many thanks Ben - The problem may be a bit more complex. When a Python executor runs, there appears to be some conflict with gevent (based on libevent) if it's running elsewhere in the code.
Even with an os.fork() within Executor.launchTask, then detaching the child process, use of gevent within the child process will throw a KeyError exception about only running one thread. Same issue with or without monkey patch. For curiosity sake, I tried using the multiprocessing package, and also python-daemon. The latter really lit my hair on fire -- within a double-forked daemon, gevent still barfs. Finally just used subprocess to launch a child process from shell. That works well enough. Still more to go, but for now here's a working example of a Py framework in Mesos: https://github.com/ceteri/exelixi Will work more on it -- e.g. the hash ring is not enabled yet, so it only one shard / one executor, etc. Working to turn its readme/wiki into a Py tutorial, too. If anyone is interested in GAs, feedback is most appreciated. Niklaus and Jason were helping / looking over my shoulder a bit -- can backtrack now with gevent, since we know exactly were to recreate the issue, then dig deeper with strace and pdb. I did not need to run gevent on the Framework side, so I did not confirm the issue there. Curious to see if the move to libev instead of libevent in the upcoming release (1.0) of gevent changes this issue: http://blog.gevent.org/2011/04/28/libev-and-libevent/ On Tue, Nov 26, 2013 at 9:36 PM, Benjamin Hindman <[email protected]>wrote: > Hey Paco, > > The semantics of Scheduler's and Executor's is that only one callback will > be invoked at at time. So if you don't return from Executor.launchTask then > you won't get any more callbacks, hence the use of threading. Feel free to > use any other means of invoking the task, just as long as you can return > from Executor.launchTask in a timely fashion (read: not after the task has > finished). > > Hope that helps, > > Ben. > > > On Mon, Nov 25, 2013 at 3:46 PM, Paco Nathan <[email protected]> wrote: > > > I'm building a distributed framework based on Mesos, in Python, using > these > > as a basis: > > > > > https://github.com/apache/mesos/blob/master/src/examples/python/test_framework.py > > > > > https://github.com/apache/mesos/blob/master/src/examples/python/test_executor.py > > > > Within the executor, I need to run a service and would like to use > > gevent.wsgi > > http://www.gevent.org/gevent.wsgi.html > > > > Looking at "test_executor.py" line 48, obviously that test code uses the > > "threading" package, with conflicts with gevent, Greenlets, etc. > > > > Question: > > However, will there be any problem with Mesos conflics vs. gevent and > > libevent in general if I back out the use of "threading" and say replace > > the "run_task()" call inside of "launch_task()" as a Greenlet? > > > > I'm trying this out -- just concerned that it may lead to other problems > > somewhere down the line... Loss of gevent would truly be a sad panda > > thing. > > > > Many thanks, > > Paco > > >
