Permalink
Browse files

changes / fixes

  • Loading branch information...
1 parent 6b05dcd commit 321c5599219381dadad2079206c14898564866e9 @rep committed Jul 14, 2011
Showing with 18 additions and 11 deletions.
  1. +15 −8 evnet/__init__.py
  2. +3 −3 evnet/mongodb.py
View
@@ -42,9 +42,12 @@ def hint(sock):
def loop(l=default_loop):
sigint_watcher = pyev.Signal(signal.SIGINT, default_loop, _sigint_cb)
sigint_watcher.start()
-
- if pyev.version()[1] < '4.00': l.loop()
- else: l.start()
+
+ try:
+ if pyev.version()[1] < '4.00': l.loop()
+ else: l.start()
+ except OSError, e:
+ print 'oserror', e, e.args
def unloop(l=default_loop):
for cb in shutdown_callbacks:
@@ -391,7 +394,7 @@ def initiate(self):
self.write_watcher.callback = self._connected
self.write_watcher.start()
else:
- logging.critical('socket.error != EINPROGRESS: {0}'.format(eno))
+ logging.critical('socket.error != EINPROGRESS: {0}'.format(errno.errorcode[eno]))
self._close('Exception.')
@@ -537,14 +540,16 @@ def initiate(self):
class pyevThread(threading.Thread):
+ daemon = True
+
def __init__(self):
threading.Thread.__init__(self)
self.aw = pyev.Async(default_loop, self.process)
self.aw.start()
self.calls = []
def run(self):
- default_loop.loop()
+ default_loop.start()
def process(self, w, e):
l = len(self.calls)
@@ -564,9 +569,11 @@ def process(self, w, e):
def blockingCall(self, f, *a, **kw):
q = Queue.Queue()
def tmpcaller():
- r = f(*a, **kw)
- r._when(q.put)
- r._except(q.put)
+ try: r = f(*a, **kw)
+ except Exception, e: q.put(e)
+ else:
+ r._when(q.put)
+ r._except(q.put)
self.calls.append((tmpcaller, [], {}))
self.aw.send()
r = q.get()
View
@@ -117,13 +117,13 @@ def command(self, db, cmd, value=1, **kwargs):
p = Promise()
cmdson = bson.SON([(cmd, value)])
cmdson.update(kwargs)
- reqid = self._sonquery('{0}.$cmd'.format(db), cmdson, limit=-1)
+ reqid = self._sonquery('{0}.$cmd'.format(db), cmdson, limit=0)
self.pqs[reqid] = (p, '{0}.$cmd'.format(db), [])
return p
- def query(self, coll, q, limit=-1):
+ def query(self, coll, q, limit=0, fields=None):
p = Promise()
- reqid = self._sonquery(coll, bson.SON({'$query': q}), limit=limit)
+ reqid = self._sonquery(coll, bson.SON({'$query': q}), limit=limit, fields=fields)
self.pqs[reqid] = (p, coll, [])
return p

0 comments on commit 321c559

Please sign in to comment.