[viff-devel] Confusing behaviour?
Martin Geisler
mg at daimi.au.dk
Wed Mar 25 17:05:15 PDT 2009
Thomas P Jakobsen <thomas.jak at gmail.com> writes:
> By the way, the same thing seem sto happen if the protocol, insted of
> asking the user to press enter, does some local computations like
> quering a database, sleeping, computing primes or the like. [...]
Right -- callback functions *cannot block*! They must always returns
very quickly and use some asynchronous mechanism to signal when a
long-running operations is finished. See this FAQ:
http://twistedmatrix.com/trac/wiki/FrequentlyAskedQuestions#HowdoIuseDeferredstomakemyblockingcodenon-blocking
Twisted has a database abstraction layer that does this for databases:
http://twistedmatrix.com/projects/core/documentation/howto/rdbms.html
And a threadpool for more general tasks:
http://twistedmatrix.com/projects/core/documentation/howto/threading.html
For non-blocking access to stdin and stdout there is the
twisted.internet.stdio module, see:
http://twistedmatrix.com/trac/browser/trunk/doc/core/examples/stdiodemo.py
This means that your example should look similar to this:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.py
Type: text/x-python
Size: 1644 bytes
Desc: not available
URL: <http://lists.viff.dk/pipermail/viff-devel-viff.dk/attachments/20090326/f870ff4d/attachment.py>
-------------- next part --------------
--
Martin Geisler
VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multiparty Computation) to Python. See: http://viff.dk/.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.viff.dk/pipermail/viff-devel-viff.dk/attachments/20090326/f870ff4d/attachment.pgp>
More information about the viff-devel
mailing list