Commits

Ronny Pfannschmidt committed 6026a6f

prepare a bit for the new api, add testrunning script

Comments (0)

Files changed (2)

     def timer(self, after, repeat=0):
         return timer(self, after, repeat)
 
+    def callback(self):
+        return callback(self)
+
+    def fork(self, ref=True):
+        return fork(self)
+
     def run(self):
         gtk.main()
 
+
+
+
 class io(object):
     def __init__(self, loop, fd, events):
         self.loop = loop
             self.fd, flags, self._callback)
 
     def _callback(self, source, condition):
-        print 'io callback', source, condition
         try:
             self.callback(*self.args)
         except:
         #XXX: check this never raises
         glib.source_remove(self.source_id)
 
+class callback(object):
+    def __init__(self, loop):
+        self.callback = None
+        self.args = None
+
+    def run_once(self):
+        self.callback(*self.args)
+
+    def start(self, callback, *args):
+        self.callback = callback
+        self.args = args
+        glib.idle_add(self.run_once)
+
+    def stop(self):
+        pass
+
+class fork(object):
+    #XXX: noop
+    def __init__(self, loop):
+        pass
+#!/usr/bin/python
+import os
+from os.path import dirname, abspath, join as pjoin
+import sys
+import subprocess
+import gevent
+gevent_base = abspath(dirname(dirname(gevent.__file__)))
+testdir = pjoin(gevent_base, 'greentest')
+testrunner = pjoin(testdir, 'testrunner.py')
+
+loopdir = abspath(dirname(__file__))
+
+pythonpath = os.environ.get('PYTHONPATH', '')
+if pythonpath:
+    pythonpath += ':' + loopdir
+else:
+    pythonpath = loopdir
+
+os.chdir(testdir)
+env = dict(os.environ,
+    PYTHONPATH=pythonpath,
+    GEVENT_LOOP='gtkloop.GtkLoop',
+)
+
+os.execve(sys.executable,
+          [sys.executable, testrunner] + sys.argv[1:],
+          env)