librelist archives

« back to archive

python handler issue

python handler issue

From:
Dhruv Matani
Date:
2011-07-31 @ 16:45
Hello,
  I keep getting a URL request for the path @* when using the python
handler. Any idea why?

-- 
   -Dhruv Matani.
http://dhruvbird.com/

"What's the simplest thing that could possibly work?"
-- Ward Cunningham

Re: [mongrel2] python handler issue

From:
Zed A. Shaw
Date:
2011-07-31 @ 17:06
On Sun, Jul 31, 2011 at 10:15:47PM +0530, Dhruv Matani wrote:
> Hello,
>   I keep getting a URL request for the path @* when using the python
> handler. Any idea why?

That's a disconnect message.  You get that when you tried to send to a
browser's conn_id that closed the socket.  You should either use the
conn_id it gives you to close any state you've got for them, or just
ignore it.

I may make that a flag on the connection actually.  Just set it to
ignore disconnects if you don't need to track state.

Zed

Re: [mongrel2] python handler issue

From:
Dhruv Matani
Date:
2011-08-01 @ 02:46
On Sun, Jul 31, 2011 at 10:36 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:
> On Sun, Jul 31, 2011 at 10:15:47PM +0530, Dhruv Matani wrote:
>> Hello,
>>   I keep getting a URL request for the path @* when using the python
>> handler. Any idea why?
>
> That's a disconnect message.  You get that when you tried to send to a
> browser's conn_id that closed the socket.  You should either use the
> conn_id it gives you to close any state you've got for them, or just
> ignore it.
>
> I may make that a flag on the connection actually.  Just set it to
> ignore disconnects if you don't need to track state.

yeah! that would be great. What was happening was that my code was
responding with a 404 to that request, and the same request came back
again - indefinitely!

btw, is this (and potentially other behaviour that I should be aware
of) documented anywhere?

Regards,
-Dhruv.

>
> Zed
>



-- 
   -Dhruv Matani.
http://dhruvbird.com/

"What's the simplest thing that could possibly work?"
-- Ward Cunningham

Re: [mongrel2] python handler issue

From:
Zed A. Shaw
Date:
2011-08-02 @ 01:59
On Mon, Aug 01, 2011 at 08:16:07AM +0530, Dhruv Matani wrote:
> > I may make that a flag on the connection actually.  Just set it to
> > ignore disconnects if you don't need to track state.
> 
> yeah! that would be great. What was happening was that my code was
> responding with a 404 to that request, and the same request came back
> again - indefinitely!

> btw, is this (and potentially other behaviour that I should be aware
> of) documented anywhere?

Should be documented and there's code sample at
examples/http_0mq/http.py which you can look at.  Let me know if it
needs more explaining since I'm hitting the docs tonight.

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] python handler issue

From:
Josh Simmons
Date:
2011-08-01 @ 02:55
On Mon, Aug 1, 2011 at 12:46 PM, Dhruv Matani <dhruvbird@gmail.com> wrote:
>
> btw, is this (and potentially other behaviour that I should be aware
> of) documented anywhere?
>
> Regards,
> -Dhruv.
>

It's all documented in the manual but there's no succinct FAQ kind of
thing if that's what you're after.

http://mongrel2.org/static/mongrel2-manual.html

Cheers,
Josh.

Re: [mongrel2] python handler issue

From:
Dhruv Matani
Date:
2011-08-01 @ 05:35
On Mon, Aug 1, 2011 at 8:25 AM, Josh Simmons <simmons.44@gmail.com> wrote:
> On Mon, Aug 1, 2011 at 12:46 PM, Dhruv Matani <dhruvbird@gmail.com> wrote:
>>
>> btw, is this (and potentially other behaviour that I should be aware
>> of) documented anywhere?
>>
>> Regards,
>> -Dhruv.
>>
>
> It's all documented in the manual but there's no succinct FAQ kind of
> thing if that's what you're after.
>
> http://mongrel2.org/static/mongrel2-manual.html

I checked here to start with, but couldn't find any mention of "@*" on
that page.

Regards,
-Dhruv.

Re: [mongrel2] python handler issue

From:
Nathan Duran
Date:
2011-08-01 @ 05:41
On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:

> I checked here to start with, but couldn't find any mention of "@*" on
> that page.

There isn't one that I've seen, and I did get tripped up by this myself 
for a few minutes when I first started building a custom Ruby handler, but
the reference Python implementation does illustrate proper handling of 
disconnect messages. 


---
 Nathan Duran
http://khiltd.com

Re: [mongrel2] python handler issue

From:
Zed A. Shaw
Date:
2011-08-02 @ 02:01
On Sun, Jul 31, 2011 at 10:41:35PM -0700, Nathan Duran wrote:
> 
> On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:
> 
> > I checked here to start with, but couldn't find any mention of "@*" on
> > that page.
> 
> There isn't one that I've seen, and I did get tripped up by this myself 
for a few minutes when I first started building a custom Ruby handler, but
the reference Python implementation does illustrate proper handling of 
disconnect messages. 

There's this now:

http://mongrel2.org/static/mongrel2-manual.html#x1-790005.4

But I'm thinking you're looking for:

"Aside:  HEY IMPLEMENTERS, HERE'S A LIST OF CRAP YOU KEEP GETTING
WRONG:" and then just points like, disconnects, send_id/recv_id, etc.?

Any others?

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] python handler issue

From:
Dhruv Matani
Date:
2011-08-02 @ 03:25
On Tue, Aug 2, 2011 at 7:31 AM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:
> On Sun, Jul 31, 2011 at 10:41:35PM -0700, Nathan Duran wrote:
>>
>> On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:
>>
>> > I checked here to start with, but couldn't find any mention of "@*" on
>> > that page.
>>
>> There isn't one that I've seen, and I did get tripped up by this myself
for a few minutes when I first started building a custom Ruby handler, but
the reference Python implementation does illustrate proper handling of 
disconnect messages.
>
> There's this now:
>
> http://mongrel2.org/static/mongrel2-manual.html#x1-790005.4
>
> But I'm thinking you're looking for:
>
> "Aside:  HEY IMPLEMENTERS, HERE'S A LIST OF CRAP YOU KEEP GETTING
> WRONG:" and then just points like, disconnects, send_id/recv_id, etc.?

yeah! precisely! and a nice bold title along with it for people like me :)
basically, everything that needs to be handled in production, but is
never addressed in examples to keep the code small.

>
> Any others?

minor nit: is_disconnected() left me wondering what it means. Of
course, if you think a bit, it's obvious that it means "is the client
disconnected", but was wondering if it could be make more in-my-face.
Of course, changing API is bad, so I wouldn't insist.

Regards,
-Dhruv.

Re: [mongrel2] python handler issue

From:
Josh Simmons
Date:
2011-08-02 @ 02:15
On Tue, Aug 2, 2011 at 12:01 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:
> On Sun, Jul 31, 2011 at 10:41:35PM -0700, Nathan Duran wrote:
>>
>> On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:
>>
>> > I checked here to start with, but couldn't find any mention of "@*" on
>> > that page.
>>
>> There isn't one that I've seen, and I did get tripped up by this myself
for a few minutes when I first started building a custom Ruby handler, but
the reference Python implementation does illustrate proper handling of 
disconnect messages.
>
> There's this now:
>
> http://mongrel2.org/static/mongrel2-manual.html#x1-790005.4
>
> But I'm thinking you're looking for:
>
> "Aside:  HEY IMPLEMENTERS, HERE'S A LIST OF CRAP YOU KEEP GETTING
> WRONG:" and then just points like, disconnects, send_id/recv_id, etc.?
>
> Any others?
>
> --
> Zed A. Shaw
> http://zedshaw.com/
>

So at some point has the disconnect message changed from

   return self.headers['METHOD'] == 'JSON' and self.data.type == 'disconnect'

to a magic path? It's been a while since I've looked at the python
implementation.

Cheers,
Josh.

Re: [mongrel2] python handler issue

From:
Zed A. Shaw
Date:
2011-08-02 @ 06:13
On Tue, Aug 02, 2011 at 12:15:08PM +1000, Josh Simmons wrote:
> So at some point has the disconnect message changed from
> 
>    return self.headers['METHOD'] == 'JSON' and self.data.type == 'disconnect'
> 
> to a magic path? It's been a while since I've looked at the python
> implementation.

Ok, so this needs some docs, probably a walk through the python code so
people implementing their own won't freak and say "magic" when it
actually makes sense.

The original idea was "@*" would be a kind of "broadcast alert" saying
that any handler receiving this should process it.  There's no
particular reason for picking it other than most of the time you
wouldn't have a route named that.

Then there's headers to check, in this case looking for the disconnect
message, which incidentally your clients can send as well to do this
gracefully for the json connections.

But, I'll write something up and explain it so that people know what it
does.

-- 
Zed A. Shaw
http://zedshaw.com/

Re: [mongrel2] python handler issue

From:
Dhruv Matani
Date:
2011-08-02 @ 03:26
On Tue, Aug 2, 2011 at 7:45 AM, Josh Simmons <simmons.44@gmail.com> wrote:
> On Tue, Aug 2, 2011 at 12:01 PM, Zed A. Shaw <zedshaw@zedshaw.com> wrote:
>> On Sun, Jul 31, 2011 at 10:41:35PM -0700, Nathan Duran wrote:
>>>
>>> On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:
>>>
>>> > I checked here to start with, but couldn't find any mention of "@*" on
>>> > that page.
>>>
>>> There isn't one that I've seen, and I did get tripped up by this 
myself for a few minutes when I first started building a custom Ruby 
handler, but the reference Python implementation does illustrate proper 
handling of disconnect messages.
>>
>> There's this now:
>>
>> http://mongrel2.org/static/mongrel2-manual.html#x1-790005.4
>>
>> But I'm thinking you're looking for:
>>
>> "Aside:  HEY IMPLEMENTERS, HERE'S A LIST OF CRAP YOU KEEP GETTING
>> WRONG:" and then just points like, disconnects, send_id/recv_id, etc.?
>>
>> Any others?
>>
>> --
>> Zed A. Shaw
>> http://zedshaw.com/
>>
>
> So at some point has the disconnect message changed from
>
>   return self.headers['METHOD'] == 'JSON' and self.data.type == 'disconnect'
>
> to a magic path? It's been a while since I've looked at the python
> implementation.

yeah, agreed. maybe a doc. containing all magic paths with 1 line to
describe them.

Regards,
-Dhruv.

Re: [mongrel2] python handler issue

From:
Dhruv Matani
Date:
2011-08-01 @ 05:49
On Mon, Aug 1, 2011 at 11:11 AM, Nathan Duran <principal@khiltd.com> wrote:
>
> On Jul 31, 2011, at 10:35 PM, Dhruv Matani wrote:
>
>> I checked here to start with, but couldn't find any mention of "@*" on
>> that page.
>
> There isn't one that I've seen, and I did get tripped up by this myself 
for a few minutes when I first started building a custom Ruby handler, but
the reference Python implementation does illustrate proper handling of 
disconnect messages.

is this the line you are referring to?
if req.is_disconnect():


>
>
> ---
>  Nathan Duran
> http://khiltd.com
>
>



-- 
   -Dhruv Matani.
http://dhruvbird.com/

"What's the simplest thing that could possibly work?"
-- Ward Cunningham