On 12:24 pm, grigorescu_cipr...@yahoo.com wrote:
Hello,
I have wrote a custom protocol(inherit from SMTPClient) and factory(inherit from ClientFactory) in order to send emails from multiple ips(multiple connections, factories).

Now I want to run this pice of code multiple times using spawnProcess to send emails simultaneous, each process having "n" connections from "n" ips.

How can i use spawnProcess? Or is another way to send emails in a parallel fashion with twisted? Maybe another approach?

You don't need multiple processes to send email concurrently. If you were to use `twisted.mail.smtp.sendmail`, then you could do this by just making multiple calls to `sendmail`. You don't have to wait for one email to be completely sent before you start trying to send the next one. For example, to send two emails concurrently:


   from sys import stdout

   from twisted.mail.smtp import sendmail
   from twisted.internet.defer import gatherResults
   from twisted.internet.task import react
   from twisted.python.log import startLogging

   def main():
       return gatherResults([
           sendmail(...),
           sendmail(...),
       ])

   startLogging(stdout)
   react(main, [])

You should be able to do something similar with the API you've constructed (or perhaps you can just use `sendmail` instead).

Jean-Paul

_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to