[Twisted-Python] Multiple clients

2010-06-18 Thread Balogh Szabolcs
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 sep

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread exarkun
On 10:36 am, bszabo...@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

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Szabolcs Balogh
I have used the following code, which is working until I called it multiple time: class ImapProtocol(twisted.mail.imap4.IMAP4Client): ... implementation ... class ImapFactory(twisted.internet.protocol.ClientFactory): def __init__(self, account): self.accou

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Phil Mayers
On 18/06/10 15:34, Szabolcs Balogh wrote: > def get_mailbox_list(self): > twisted.internet.reactor.run() > The reactor isn't restartable. You can only start it once. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://t

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Szabolcs Balogh
On Friday 18 June 2010 17:49:27 Phil Mayers wrote: > On 18/06/10 15:34, Szabolcs Balogh wrote: > > def get_mailbox_list(self): > > twisted.internet.reactor.run() > > The reactor isn't restartable. You can only start it once. > > ___ > Twis

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Jason J. W. Williams
Couldn't you use callLater to fire the first account check every N interval and then just attach the subsequent accounts for that interval as callbacks to the first check inside your callLater func? -J On Fri, Jun 18, 2010 at 9:25 AM, Szabolcs Balogh wrote: > On Friday 18 June 2010 17:49:27 Phil

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Glyph Lefkowitz
On Jun 18, 2010, at 8:25 AM, Szabolcs Balogh wrote: > Than how can I start checking for messages for different accounts (When I > have > finished checking the messages for the first account to start checking for > the > next account, and so on...)? The whole *point* of the "reactor" is to al

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Phil Mayers
On 18/06/10 16:25, Szabolcs Balogh wrote: > On Friday 18 June 2010 17:49:27 Phil Mayers wrote: >> On 18/06/10 15:34, Szabolcs Balogh wrote: >>> def get_mailbox_list(self): >>> twisted.internet.reactor.run() >> >> The reactor isn't restartable. You can only start it once. >> >> _

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Szabolcs Balogh
On Friday 18 June 2010 19:24:54 Glyph Lefkowitz wrote: > On Jun 18, 2010, at 8:25 AM, Szabolcs Balogh wrote: > > Than how can I start checking for messages for different accounts (When I > > have finished checking the messages for the first account to start > > checking for the next account, and so

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Szabolcs Balogh
On Friday 18 June 2010 19:24:54 Glyph Lefkowitz wrote: > This is actually a FAQ: > > tedtalktomultipleclientsconnecttomultipleservers> > "Sometimes people ask this question when they write a function that calls connect

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Itamar Turner-Trauring
> It sounds good, but if I don't call reactor.run() after connectSSL doesn't > happens anything... If I call reactor.run() after connectSSL, it works > properly... There are two types of client connections: 1. Connections you open when you first run the program. Call these before reactor.run() is

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Szabolcs Balogh
On Friday 18 June 2010 20:25:50 Itamar Turner-Trauring wrote: > > It sounds good, but if I don't call reactor.run() after connectSSL > > doesn't happens anything... If I call reactor.run() after connectSSL, it > > works properly... > > There are two types of client connections: > > 1. Connections

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Gerrat Rickert
>It is possible to: > - start the reactor when I initialize my program (eg. in main) > - call connectTCP or connectSSL when I want and every time I want? > >Something like this: > >def check_messages(account): > # connect to imap server and check for new mailboxes/messages > reactor.con

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Jason J. W. Williams
If you're not using twistd to launch your app you'll have to run reactor.run(). Otherwise, the eventloop won't ever start. In terms of exposing something like get_messages()...couldn't that issue the callLater with a very tiny value? Or issue the first connectTCP, which the others chained via addC

Re: [Twisted-Python] Multiple clients

2010-06-18 Thread Kevin Horn
On Fri, Jun 18, 2010 at 12:55 PM, Szabolcs Balogh wrote: > > It is possible to: > - start the reactor when I initialize my program (eg. in main) > - call connectTCP or connectSSL when I want and every time I want? > > Yes, this is exactly what you are supposed to do. Call the reactor _once_ and

Re: [Twisted-Python] Twisted Names too many open files...resolv.conf

2010-06-18 Thread Jason J. W. Williams
Hi Jean-Paul, As usual you're very right on more than one front: 1.) Using Resolver() directly is exactly the behavior we wanted. 2.) Running out of file descriptors was not because of the resolv.conf. #2 was because this box had an ancient version of Twisted (2.5.0) that never stopped the Resol