On Thu, 2009-09-10 at 22:05 +0200, Johan Euphrosine wrote: > I spotted another issue with server side implementation, > > If the avatar is not connected to any tables or tourneys, > PacketPokerPollReturn expire the avatar session *before*, > PacketPokerPoll returns, thus causes the following Traceback: > > PokerResource: *ERROR* (x-forwarded-for:127.0.0.1) Traceback (most recent > call last): > File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line > 328, in _runCallbacks > self.result = callback(self.result, *args, **kw) > File "../pokernetwork/pokersite.py", line 229, in <lambda> > deferred.addCallback(lambda result: self.deferRender(request, jsonp, > packet, data)) > File "../pokernetwork/pokersite.py", line 271, in deferRender > d.addCallbacks(render, processingFailed) > File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line > 186, in addCallbacks > self._runCallbacks() > --- <exception caught here> --- > File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line > 328, in _runCallbacks > self.result = callback(self.result, *args, **kw) > File "../pokernetwork/pokersite.py", line 245, in render > session.site.updateSession(session) > File "../pokernetwork/pokersite.py", line 450, in updateSession > serial = session.avatar.getSerial() > exceptions.AttributeError: Session instance has no attribute 'avatar' > > As we discussed with Loic, one fix would be not to do anything on the > session when handling a PacketPokerLongPollReturn. > > I'll work on this, and do more testing tomorrow. >
I believe that the attached patch fix this issue,
I've done more testing and now I manage to sit (damn fast) at the table,
but when I connect another client I've got this Traceback:
PokerTable: broadcast[4, 5] type = POKER_POSITION(54) game_id = 1201, position
= 0, serial = 0
[4]PokerExplain:explain: type = POKER_POSITION(54) game_id = 1201, position =
0, serial = 0
[5]PokerExplain:explain: type = POKER_POSITION(54) game_id = 1201, position =
0, serial = 0
PokerTable: Not autodealing 1201 because game is running
PokerResource: (x-forwarded-for:127.0.0.1) render {"type":"PacketPokerLongPoll"}
PokerAvatar: handlePacketDefer(5): POKER_LONG_POLL type = 167 length = 3
PokerResource: *ERROR* (x-forwarded-for:127.0.0.1) Traceback (most recent call
last):
File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 328,
in _runCallbacks
self.result = callback(self.result, *args, **kw)
File "../pokernetwork/pokersite.py", line 229, in <lambda>
deferred.addCallback(lambda result: self.deferRender(request, jsonp,
packet, data))
File "../pokernetwork/pokersite.py", line 273, in deferRender
d.addCallbacks(render, processingFailed)
File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 186,
in addCallbacks
self._runCallbacks()
--- <exception caught here> ---
File "/usr/lib/python2.6/dist-packages/twisted/internet/defer.py", line 328,
in _runCallbacks
self.result = callback(self.result, *args, **kw)
File "../pokernetwork/pokersite.py", line 252, in render
maps = toutf8(packets2maps(packets))
File "../pokernetwork/pokersite.py", line 69, in packets2maps
for packet in packets:
exceptions.TypeError: 'NoneType' object is not iterable
I believe this might be due a border case where the long poll deferred
returns None instead of [].
I'll investigate more on this issue.
--
Johan Euphrosine <[email protected]>
Index: pokernetwork/pokersite.py
===================================================================
--- pokernetwork/pokersite.py (revision 6220)
+++ pokernetwork/pokersite.py (working copy)
@@ -241,9 +241,11 @@
def render(packets):
#
# update the session information if the avatar changed
+ # do not touch the session if handling PacketPokerLongPollReturn
#
- session.site.updateSession(session)
- session.site.persistSession(session)
+ if packet.type != PACKET_POKER_LONG_POLL_RETURN:
+ session.site.updateSession(session)
+ session.site.persistSession(session)
#
# Format answer
#
Index: pokernetwork/pokeravatar.py
===================================================================
--- pokernetwork/pokeravatar.py (revision 6222)
+++ pokernetwork/pokeravatar.py (working copy)
@@ -366,6 +366,8 @@
def longPollReturn(self):
if self._longpoll_deferred:
packets = self.resetPacketsQueue()
+ if self.service.verbose > 3:
+ self.message("longPollReturn(%s): " % str(packets))
d = self._longpoll_deferred
self._longpoll_deferred = None
d.callback(packets)
Index: tests/test-pokersite.py.in
===================================================================
--- tests/test-pokersite.py.in (revision 6220)
+++ tests/test-pokersite.py.in (working copy)
@@ -247,6 +247,21 @@
r.requestReceived('GET', '/', '')
return d
+ def test06_1_render_expire_long_poll_return(self):
+ r = pokersite.Request(self.Channel(self.site), True)
+ r.site = r.channel.site
+ input = '{"type": "PacketPokerLongPollReturn"}'
+ r.gotLength(len(input))
+ r.handleContentChunk(input)
+ d = r.notifyFinish()
+ r.args = { 'uid': [ 'uid' ], 'auth': ['auth'] }
+ session = r.getSession()
+ def finish(result):
+ self.assertEqual(False, session.expired)
+ d.addCallback(finish)
+ r.requestReceived('GET', '/?uid=uid&auth=auth', '')
+ return d
+
def test07_message_prefix(self):
r = pokersite.Request(self.Channel(self.site), True)
r.site = r.channel.site
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Pokersource-users mailing list [email protected] https://mail.gna.org/listinfo/pokersource-users
