[Twisted-Python] Multiple clients

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Fri Jun 18 07:01:02 MDT 2010


On 10:36 am, bszabolcs at gmail.com wrote:
>Hy,
>
>Can somebody send me a small example how to use multiple clients at 
>same
>time? For example to connect to 3 different IMAP server. I need this 
>because
>I'm working on an email client engine. I can connect to POP/IMAP/SMTP 
>server
>to download and send messages, but I have created those methods 
>separated,
>and each time when I check for new messages or send a message I use
>reactor.run() and reactor.stop(). But calling it multiple times is a
>problem.

Why?
>So I need something:
>- when I press button1, the application checks for new messages on POP
>server.
>- when I press button2, the application checks for new messages on IMAP
>server.

How about:

  def onbutton1(self):
      checkPOP()

  def onbutton2(self):
      checkIMAP()
>
>I know how to check for messages on IMAP/POP server, but I don't know 
>how to
>do it periodically with twisted...

Periodically as in "once every N seconds"?  Check out reactor.callLater 
or twisted.internet.task.LoopingCall.

Jean-Paul




More information about the Twisted-Python mailing list