Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 11:36, Sarah Addis wrote:
> I am currently trying to use a SMTP server to send emails. However I
> keep getting the same python authentication error outlined below. The
> SMTP server requires authentication and can advertise CRAM-MD5 as an
> accepted authentication method but fails when the client tries to use
> it. No other methods are tried after the failure, Python's smtplib just
> raises an Exception. I have attached the traceback below

Can you show how you are using the Twisted SMTP code?

IIRC the Twisted SMTP stuff has support for handling auth errors and 
trying other methods; it should "just work".

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


Re: [Twisted-Python] AMPBox as an Argument?

2012-07-24 Thread Laurens Van Houtven
Sure, I just ended up doing that.

Would it be worth creating a ticket, or am I seriously the first person to want 
this?


cheers
lvh



On 20 Jul 2012, at 10:35, Glyph wrote:

> 
> On Jul 20, 2012, at 1:11 AM, Laurens Van Houtven <_...@lvh.cc> wrote:
> 
>> Hi,
>> 
>> 
>> Apparently AMPBoxes aren't Arguments. However, I kind of want an AMPBox 
>> (like an AMPList, but only one).
>> 
>> Use case: my responses have a "location", but a location is composed of 
>> several sub-things: place name, country and postal code. {"location": 
>> {"placeName": "Krakow", "countryCode": "PL", postalCode: "30-015"}} would be 
>> a lot nicer  than having those keys in the top level namespace :)
>> 
>> cheers
>> lvh
> 
> Seems like an easy enough thing to write.  Given that AMPList doesn't use a 
> length prefix (it uses null-key box-termination, just like the rest of the 
> protocol) the representation would be exactly the same.  Just add a trivial 
> wrapper that uses AMPList, unpacks its argument, and assert that there's only 
> one of them?
> 
> -glyph
> 
> 
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Sarah Addis
Do you mean the smtp.py file? I'm not authorized to display all the code
from this file, what should I be looking for specifically?

On 24 July 2012 11:54, Phil Mayers  wrote:

> On 24/07/12 11:36, Sarah Addis wrote:
> > I am currently trying to use a SMTP server to send emails. However I
> > keep getting the same python authentication error outlined below. The
> > SMTP server requires authentication and can advertise CRAM-MD5 as an
> > accepted authentication method but fails when the client tries to use
> > it. No other methods are tried after the failure, Python's smtplib just
> > raises an Exception. I have attached the traceback below
>
> Can you show how you are using the Twisted SMTP code?
>
> IIRC the Twisted SMTP stuff has support for handling auth errors and
> trying other methods; it should "just work".
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 14:15, Sarah Addis wrote:
> Do you mean the smtp.py file? I'm not authorized to display all the code
> from this file, what should I be looking for specifically?

If you can't produce an example of how you are using Twisted, how do you 
expect people to help you?

Which APIs are you calling, and how?

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Itamar Turner-Trauring
***

On Tue, Jul 24, 2012 at 6:36 AM, Sarah Addis  wrote:

>  I am currently trying to use a SMTP server to send emails. However I
> keep getting the same python authentication error outlined below. The SMTP
> server requires authentication and can advertise CRAM-MD5 as an accepted
> authentication method but fails when the client tries to use it. No other
> methods are tried after the failure, Python's smtplib just raises an
> Exception.
>
As Phil mentioned, a code example would be useful (what API are you
calling, at the very least?).

A priori, however, this issue might happen for a number of reasons:

   1. You're using the wrong username or password (did you try in an email
   client like Thunderbird?).
   2. Twisted's CRAM-MD5 implementation is buggy.
   3. The SMTP server's CRAM-MD5 implementation is buggy.
   4. Bad description of issue in the SMTP server response - do the SMTP
   server logs say anything additional?

Once you've ruled out options #1 and #4, for options #2 and #3 disabling
CRAM-MD5 might help (though it'd be nice to figure out if there's some way
Twisted could be changed to work with this SMTP server). While slightly
annoying since it involves a bunch of repetition of code already in
Twisted, disabling CRAM-MD5 should be pretty straightforward, and if you're
using SSL or connecting to an SMTP server on localhost isn't really much of
a reduction in security. If you have some indication that CRAM-MD5 is a
problem with this particular server, filing a ticket for that on
http://twistedmatrix.com might be nice.

-- 
Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] AMPBox as an Argument?

2012-07-24 Thread exarkun
On 12:48 pm, _...@lvh.cc wrote:
>Sure, I just ended up doing that.
>
>Would it be worth creating a ticket, or am I seriously the first person 
>to want this?

Some general dict argument types would be great.  The kind represented 
by AMPList included.  Note that once we have this, AMPList can actually 
be implemented in like ListOf(Dict()) instead of being a special case. 
This argues against implementing Dict in terms of AMPList, though. ;)

Jean-Paul
>
>cheers
>lvh
>
>
>
>On 20 Jul 2012, at 10:35, Glyph wrote:
>>
>>On Jul 20, 2012, at 1:11 AM, Laurens Van Houtven <_...@lvh.cc> wrote:
>>>Hi,
>>>
>>>
>>>Apparently AMPBoxes aren't Arguments. However, I kind of want an 
>>>AMPBox (like an AMPList, but only one).
>>>
>>>Use case: my responses have a "location", but a location is composed 
>>>of several sub-things: place name, country and postal code. 
>>>{"location": {"placeName": "Krakow", "countryCode": "PL", postalCode: 
>>>"30-015"}} would be a lot nicer  than having those keys in the top 
>>>level namespace :)
>>>
>>>cheers
>>>lvh
>>
>>Seems like an easy enough thing to write.  Given that AMPList doesn't 
>>use a length prefix (it uses null-key box-termination, just like the 
>>rest of the protocol) the representation would be exactly the same. 
>>Just add a trivial wrapper that uses AMPList, unpacks its argument, 
>>and assert that there's only one of them?
>>
>>-glyph
>>
>>
>>___
>>Twisted-Python mailing list
>>Twisted-Python@twistedmatrix.com
>>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
>___
>Twisted-Python mailing list
>Twisted-Python@twistedmatrix.com
>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Itamar Turner-Trauring
On Tue, Jul 24, 2012 at 6:54 AM, Phil Mayers wrote:

> IIRC the Twisted SMTP stuff has support for handling auth errors and
> trying other methods; it should "just work".
>

The code is a bit convoluted, so I can't be sure without more time than I
want to spend on it, but I wouldn't expect it to try more than one auth
method. If you send your username and password with CRAM-MD5 and got an
error, why would you expect it to work with some other authentication
method? It's still the same credentials.
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Jessica McKellar
Phil, that was rather brusque; let's keep things friendly and supportive here.

Sarah, can you try to condense your code into a short, self-contained
example (http://sscce.org/) that you can share with us? That would be
very helpful.

Regards,
-Jessica


On Tue, Jul 24, 2012 at 9:28 AM, Phil Mayers  wrote:
> On 24/07/12 14:15, Sarah Addis wrote:
>> Do you mean the smtp.py file? I'm not authorized to display all the code
>> from this file, what should I be looking for specifically?
>
> If you can't produce an example of how you are using Twisted, how do you
> expect people to help you?
>
> Which APIs are you calling, and how?
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 14:29, Itamar Turner-Trauring wrote:

>  3. The SMTP server's CRAM-MD5 implementation is buggy.

If I understand the issue correctly, this is the case. The server 
incorrectly advertises CRAM-MD5, but it never succeeds since the server 
lacks the relevant secret.

Obviously this is bad, but apparently many GUI clients handle such 
broken servers, by falling back to PLAIN auth. I can't say I've ever 
seen it in the wild though.


Although I haven't used it in a while, my recollection was that 
Twisted's SMTPClient implementation did a similar thing, and tried the 
auth methods it was supplied "in order".

It may be that the OP is using some wrapper API or local code that is 
mis-using this functionality, or of course that I am mis-remembering it.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Sarah Addis
Sorry to be unhelpful in describing the issue. The password and username
credentials are all correct. I am using BuildBot MailNotifier to send an
email each time a build has taken place:

 from buildbot.status import mail

 c['status'].append(mail.MailNotifier(

 fromaddr="bu...@companyname.co.uk",
 extraRecipients=[exam...@companyname.com",],

 sendToInterestedUsers=False,
 mode='all',
 relayhost="smtp.companyname.lan",

 useTls=False,
 smtpUser="username",
 smtpPassword="password"))


I am a new user to twisted and am unsure of what it would be helpful to
show. The traceback I have shown is from the twistd.log. If I can't expect
it to work with some other authentication method then how can the problem
be resolved?

On 24 July 2012 14:31, Itamar Turner-Trauring wrote:

>
>
> On Tue, Jul 24, 2012 at 6:54 AM, Phil Mayers wrote:
>
>> IIRC the Twisted SMTP stuff has support for handling auth errors and
>> trying other methods; it should "just work".
>>
>
> The code is a bit convoluted, so I can't be sure without more time than I
> want to spend on it, but I wouldn't expect it to try more than one auth
> method. If you send your username and password with CRAM-MD5 and got an
> error, why would you expect it to work with some other authentication
> method? It's still the same credentials.
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 14:31, Itamar Turner-Trauring wrote:
>
>
> On Tue, Jul 24, 2012 at 6:54 AM, Phil Mayers  > wrote:
>
> IIRC the Twisted SMTP stuff has support for handling auth errors and
> trying other methods; it should "just work".
>
>
> The code is a bit convoluted, so I can't be sure without more time than
> I want to spend on it, but I wouldn't expect it to try more than one
> auth method. If you send your username and password with CRAM-MD5 and
> got an error, why would you expect it to work with some other
> authentication method? It's still the same credentials.

Normally I'd agree. Unfortunately, SMTP like many other SASL-like 
protocols presents the list of auth methods BEFORE the username is supplied.

The server may have different secret formats for different users; maybe 
older accounts, whose passwords haven't changed in a while, only have a 
unix-style crypt whereas newer ones have the MD5 secret as well.

I still think it's bad/buggy server behaviour to present an auth method 
unless it can DEFINITELY service it for all clients. But if I understand 
the issue correctly, that behaviour exists in the wild.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Sarah Addis
Ok.. so I have found this piece of code in my smtp.py file:

def _registerAuthenticators(self):
# Register Authenticator in order from most secure to least secure

self.registerAuthenticator(CramMD5ClientAuthenticator(self.username))
self.registerAuthenticator(LOGINAuthenticator(self.username))
self.registerAuthenticator(PLAINAuthenticator(self.username))

so if I switch the order around to put PLAINAuthenticator first will this
hopefully work?

On 24 July 2012 14:54, Phil Mayers  wrote:

> On 24/07/12 14:29, Itamar Turner-Trauring wrote:
>
> >  3. The SMTP server's CRAM-MD5 implementation is buggy.
>
> If I understand the issue correctly, this is the case. The server
> incorrectly advertises CRAM-MD5, but it never succeeds since the server
> lacks the relevant secret.
>
> Obviously this is bad, but apparently many GUI clients handle such
> broken servers, by falling back to PLAIN auth. I can't say I've ever
> seen it in the wild though.
>
>
> Although I haven't used it in a while, my recollection was that
> Twisted's SMTPClient implementation did a similar thing, and tried the
> auth methods it was supplied "in order".
>
> It may be that the OP is using some wrapper API or local code that is
> mis-using this functionality, or of course that I am mis-remembering it.
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 14:43, Jessica McKellar wrote:
> Phil, that was rather brusque; let's keep things friendly and supportive here.

That was not my intention. It was terse because I replied in a hurry, 
since I have a day job.

Still, if anyone was offended, then I apologise.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 14:31, Itamar Turner-Trauring wrote:
>
>
> On Tue, Jul 24, 2012 at 6:54 AM, Phil Mayers  > wrote:
>
> IIRC the Twisted SMTP stuff has support for handling auth errors and
> trying other methods; it should "just work".
>
>
> The code is a bit convoluted, so I can't be sure without more time than
> I want to spend on it, but I wouldn't expect it to try more than one

Actually, I think you're right. I am either not remembering the function 
correctly, or it has changed.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 15:16, Sarah Addis wrote:
> Ok.. so I have found this piece of code in my smtp.py file:
>
>  def _registerAuthenticators(self):
>  # Register Authenticator in order from most secure to least secure
>
> self.registerAuthenticator(CramMD5ClientAuthenticator(self.username))
>  self.registerAuthenticator(LOGINAuthenticator(self.username))
>  self.registerAuthenticator(PLAINAuthenticator(self.username))
>
> so if I switch the order around to put PLAINAuthenticator first will
> this hopefully work?

Should do, if I understand the code correctly. See my other email for a 
different approach.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 15:00, Sarah Addis wrote:
> Sorry to be unhelpful in describing the issue. The password and username
> credentials are all correct. I am using BuildBot MailNotifier to send an
> email each time a build has taken place:

Ok, upon closer examination my recollection is incorrect; Twisted will 
always try CRAM-MD5 first.

As far as I can tell, you will need to sub-class the relevant classes 
and disable the CRAM-MD5 support. Sadly, this will require using an 
internal Twisted API, e.g.

from twisted.mail.smtp import ESMTPSender, ESMTPSenderFactory
from twisted.mail.smtp import LOGINAuthenticator, PLAINAuthenticator

class MyESMTP(ESMTPSender):
   def _registerAuthenticators(self):
  self.registerAuthenticator(LOGINAuthenticator(self.username))
  self.registerAuthenticator(PLAINAuthenticator(self.username))

# monkeypatch hack!
ESMTPSenderFactory.protocol = MyESMTP


This can be done more cleanly, of course.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 15:00, Sarah Addis wrote:
> Sorry to be unhelpful in describing the issue. The password and username
> credentials are all correct. I am using BuildBot MailNotifier to send an
> email each time a build has taken place:

One thing - which email server is this, and can you confirm for certain 
that some mainstream SMTP client (e.g. Thunderbird, Outlook) can send 
emails via it?

If so, someone should open a Twisted ticket to make t.m.smtp handle auth 
method chaining - it doesn't look too hard.

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Itamar Turner-Trauring
On Tue, Jul 24, 2012 at 9:54 AM, Phil Mayers wrote:

> On 24/07/12 14:29, Itamar Turner-Trauring wrote:
>
> >  3. The SMTP server's CRAM-MD5 implementation is buggy.
>
> If I understand the issue correctly, this is the case. The server
> incorrectly advertises CRAM-MD5, but it never succeeds since the server
> lacks the relevant secret.
>
> Obviously this is bad, but apparently many GUI clients handle such
> broken servers, by falling back to PLAIN auth. I can't say I've ever
> seen it in the wild though.
>

Could you file a ticket for implementing this functionality?
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 15:07, Phil Mayers wrote:

> I still think it's bad/buggy server behaviour to present an auth method
> unless it can DEFINITELY service it for all clients. But if I understand
> the issue correctly, that behaviour exists in the wild.

This (and onward links) is relevant, perhaps:

https://bugzilla.mozilla.org/show_bug.cgi?id=311657

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Sarah Addis
THANK YOU- the email is now working after switching about the auth modes :)
:) :)

On 24 July 2012 15:26, Phil Mayers  wrote:

> On 24/07/12 14:31, Itamar Turner-Trauring wrote:
> >
> >
> > On Tue, Jul 24, 2012 at 6:54 AM, Phil Mayers  > > wrote:
> >
> > IIRC the Twisted SMTP stuff has support for handling auth errors and
> > trying other methods; it should "just work".
> >
> >
> > The code is a bit convoluted, so I can't be sure without more time than
> > I want to spend on it, but I wouldn't expect it to try more than one
>
> Actually, I think you're right. I am either not remembering the function
> correctly, or it has changed.
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Itamar Turner-Trauring
On Tue, Jul 24, 2012 at 10:16 AM, Sarah Addis  wrote:

> Ok.. so I have found this piece of code in my smtp.py file:
>
> def _registerAuthenticators(self):
> # Register Authenticator in order from most secure to least secure
>
> self.registerAuthenticator(CramMD5ClientAuthenticator(self.username))
> self.registerAuthenticator(LOGINAuthenticator(self.username))
> self.registerAuthenticator(PLAINAuthenticator(self.username))
>
> so if I switch the order around to put PLAINAuthenticator first will this
> hopefully work?
>

Yes, or just remove CRAMMD5 altogether. Unfortunately, this involves a
bunch of copy/pasting to recreate sendmail() or ESMTPSenderFactory with an
ESMTPClient that doesn't have that line, or editing Twisted code, but it
should solve it hopefully.

The fix Phil suggested (falling back if CRAM-MD5 fails) would solve this
long term, as would some way to specify which authenticators you want as
part of the high-level sendmail() API.
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Sarah Addis
It is an internal company server.

On 24 July 2012 15:32, Phil Mayers  wrote:

> On 24/07/12 15:00, Sarah Addis wrote:
> > Sorry to be unhelpful in describing the issue. The password and username
> > credentials are all correct. I am using BuildBot MailNotifier to send an
> > email each time a build has taken place:
>
> One thing - which email server is this, and can you confirm for certain
> that some mainstream SMTP client (e.g. Thunderbird, Outlook) can send
> emails via it?
>
> If so, someone should open a Twisted ticket to make t.m.smtp handle auth
> method chaining - it doesn't look too hard.
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 15:37, Itamar Turner-Trauring wrote:

> Could you file a ticket for implementing this functionality?

http://twistedmatrix.com/trac/ticket/5803

I'm not entirely happy with the description; there's actually a bunch of 
different, subtly overlapping things going on here. But at least it 
won't get lost / forgotten about.

BTW, is it me, or is Trac a bit slow? The ticketing bit was sluggish, 
but in particular the code browsing is very slow...

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


Re: [Twisted-Python] SMTP authentication

2012-07-24 Thread Phil Mayers
On 24/07/12 16:01, Sarah Addis wrote:
> It is an internal company server.

It would be helpful at least to know the product name, assuming it is an 
off-the-shelf product.

But if you can't supply it, I wouldn't worry too much.

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


[Twisted-Python] stopping a twistd daemon: SIGTERM or SIGKILL

2012-07-24 Thread Tom Sheffler
Hi Twisted Folks,

We use monit to start and stop our twistd daemons.  I have set up monit to
restart some of the daemons when they grow too large.  I use the following
command:

/bin/bash -c 'kill -s SIGTERM `cat /var/run/sensrtunw/sensrtunw.pid`'

Occasionally, this is unsuccessful in killing the twistd process, and I
need to use a SIGKILL manually as a last resort.

Any ideas why?

I believe the SIGTERM method will do a clean shutdown, calling the
appropriate stopService methods.  This would be the preferred method.

The only thing that comes to mind is that the process does have a very few
threads ... I believe these are the database connections.  Could there be a
race condition that prevents twistd from stopping?  Shall I simply use
SIGKILL in all cases?

Suggestions or comments appreciated.
-Tom
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] stopping a twistd daemon: SIGTERM or SIGKILL

2012-07-24 Thread Justin Venus
I experienced a similar issue with a rather large twisted daemon.  I ended
up installing my own signal handler and issued a triggerSystemEvent to stop
the twisted services.  I can point you towards my code if you want to
pursue that route.

Justin Venus
On Jul 24, 2012 10:21 PM, "Tom Sheffler"  wrote:

> Hi Twisted Folks,
>
> We use monit to start and stop our twistd daemons.  I have set up monit to
> restart some of the daemons when they grow too large.  I use the following
> command:
>
> /bin/bash -c 'kill -s SIGTERM `cat /var/run/sensrtunw/sensrtunw.pid`'
>
> Occasionally, this is unsuccessful in killing the twistd process, and I
> need to use a SIGKILL manually as a last resort.
>
> Any ideas why?
>
> I believe the SIGTERM method will do a clean shutdown, calling the
> appropriate stopService methods.  This would be the preferred method.
>
> The only thing that comes to mind is that the process does have a very few
> threads ... I believe these are the database connections.  Could there be a
> race condition that prevents twistd from stopping?  Shall I simply use
> SIGKILL in all cases?
>
> Suggestions or comments appreciated.
> -Tom
>
>
>
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>
___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python