class FakeReactor(object): """A fake threaded reactor, for testing.""" def __init__(self): """Initialize a fake threaded reactor, for testing.""" self.context = ContextTracker() def getThreadPool(self): """Return a new :class:`FakeThreadPool`.""" return FakeThreadPool() def callInThread(self, f, *args, **kwargs): """Just call the function with the arguments.""" self.context.callWithContext({'virtual-thread': 'non-reactor'}, f, *args, **kwargs) def callFromThread(self, f, *args, **kw): """Just call the function with the arguments.""" self.context.callWithContext({'virtual-thread': 'reactor'}, f, *args, **kw)
class FakeReactor(object): """A fake threaded reactor, for testing.""" def __init__(self): """Initialize a fake threaded reactor, for testing.""" self.context = ContextTracker() def getThreadPool(self): """Return a new :class:`FakeThreadPool`.""" return FakeThreadPool() def callInThread(self, f, *args, **kwargs): """Just call the function with the arguments.""" self.context.callWithContext({"virtual-thread": "non-reactor"}, f, *args, **kwargs) def callFromThread(self, f, *args, **kw): """Just call the function with the arguments.""" self.context.callWithContext({"virtual-thread": "reactor"}, f, *args, **kw)
def __init__(self): self.context = ContextTracker()
def __init__(self): """Initialize a fake threaded reactor, for testing.""" self.context = ContextTracker()