[Twisted-Python] Is it a good/recommended practice to pass Instance Method into reactor.callFromThread()/callInThread()?

Andrew Bennetts andrew-twisted at puzzling.org
Tue Jan 23 15:33:52 MST 2007

jian wu wrote:
> Hi Twisted Guru,
> I'm new to Twisted, I am just experimenting Twisted 2.5 with Python 2.5.
> It seems that I can pass either a python function or a python object instance
> method to reactor.callInThread() for blocking operation and
> reactor.callFromThread() in main event loop.
> I just want to see whether it is a good/recommended practice to pass Instance
> Method into reactor.callFromThread()/callInThread(), which implies that the
> application level context information stored in the python object instance is
> available when the method is invoked, so I don't have to pass all the context
> info as parameters. Do I miss anything in Twisted?

Yes, passing bound methods is fine, and often useful for the reasons you give.


More information about the Twisted-Python mailing list