def __render_locals(self, tree): gr_locals = all_local_dicts_for_greenlet(self.greenlet) if gr_locals: tree.child_data("Greenlet Locals:") for (kind, idl), vals in gr_locals: tree.child_data(" Local %s at %s" % (kind, hex(idl))) tree.child_multidata(" " + pprint.pformat(vals))
def __render_locals(self, tree): # Defer the import to avoid cycles from gevent.local import all_local_dicts_for_greenlet gr_locals = all_local_dicts_for_greenlet(self.greenlet) if gr_locals: tree.child_data("Greenlet Locals:") for (kind, idl), vals in gr_locals: tree.child_data(" Local %s at %s" % (kind, hex(idl))) tree.child_multidata(" " + pprint.pformat(vals))
def test_local_dicts_for_greenlet(self): # In fact, only on Windows do we see gc being an issue; # pypy2 5.10 on macOS and Travis don't have a problem. import gevent from gevent.local import all_local_dicts_for_greenlet x = MyLocal() x.foo = 42 del x.sentinel results = all_local_dicts_for_greenlet(gevent.getcurrent()) self.assertEqual(results, [((MyLocal, id(x)), {'foo': 42})])
def __render_locals(self, tree): # Defer the import to avoid cycles from gevent.local import all_local_dicts_for_greenlet gr_locals = all_local_dicts_for_greenlet(self.greenlet) if gr_locals: tree.child_data("Greenlet Locals:") for (kind, idl), vals in gr_locals: if not vals: continue # not set in this greenlet; ignore it. tree.child_data(" Local %s at %s" % (kind, hex(idl))) tree.child_multidata(" " + pprint.pformat(vals))
def test_local_dicts_for_greenlet(self): import gevent from gevent.local import all_local_dicts_for_greenlet x = MyLocal() x.foo = 42 del x.sentinel if greentest.PYPY: import gc gc.collect() results = all_local_dicts_for_greenlet(gevent.getcurrent()) self.assertEqual(results, [((MyLocal, id(x)), {'foo': 42})])
def _run(self): # pylint:disable=method-hidden x = local() x.foo = 42 self.id_x = id(x) self.results = all_local_dicts_for_greenlet(self)
def _run(self): # pylint:disable=method-hidden x = local() x.foo = 42 self.id_x = id(x) self.results = all_local_dicts_for_greenlet(self)