Re: [Twisted-Python] order of remote requests

2009-12-29 Thread Andrew Bennetts
Wolfgang Rohdewald wrote:
 Hi,
 
 when I send two remote calls A and B over the network, in that
 order, using the twisted perspective broker callRemote method,
 is it granted that A is processed first on the other side even
 if B  arrives first? Or should I only send B after I got an
 answer to A?

It depends on the server, and what exactly you want to happen.

Perspective broker can have many concurrent remote calls on the same
connection, and depending on how the server is implemented it might
process those sequentially in the order they arrive, or concurrently, or
even in an arbitrary order.

So if call A really must be completed before starting B, then the client
must not make call B until it knows A has finished.

-Andrew.


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


Re: [Twisted-Python] order of remote requests

2009-12-29 Thread Wolfgang Rohdewald
On Tuesday 29 December 2009, Andrew Bennetts wrote:
 Wolfgang Rohdewald wrote:
  when I send two remote calls A and B over the network, in that
  order, using the twisted perspective broker callRemote method,
  is it granted that A is processed first on the other side even
  if B  arrives first? Or should I only send B after I got an
  answer to A?
 
 It depends on the server, and what exactly you want to happen.
 
 Perspective broker can have many concurrent remote calls on the
  same connection, and depending on how the server is implemented it
  might process those sequentially in the order they arrive, or
  concurrently, or even in an arbitrary order.
 
 So if call A really must be completed before starting B, then the
  client must not make call B until it knows A has finished.

I should have given more details, sorry.

I am writing both the server and the client with twisted pb.
The server (a game server) sends messages to four player clients.

Say the game server sends messages A and B to a player client. 

Is it granted that the player client always processes A first even
if the internet routes the messages differently and B arrives
first?

-- 
Wolfgang

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


Re: [Twisted-Python] order of remote requests

2009-12-29 Thread David Ripton
On 2009.12.29 12:53:07 +0100, Wolfgang Rohdewald wrote:
 On Tuesday 29 December 2009, Andrew Bennetts wrote:
  Wolfgang Rohdewald wrote:
   when I send two remote calls A and B over the network, in that
   order, using the twisted perspective broker callRemote method,
   is it granted that A is processed first on the other side even
   if B  arrives first? Or should I only send B after I got an
   answer to A?
  
  It depends on the server, and what exactly you want to happen.
  
  Perspective broker can have many concurrent remote calls on the
   same connection, and depending on how the server is implemented it
   might process those sequentially in the order they arrive, or
   concurrently, or even in an arbitrary order.
  
  So if call A really must be completed before starting B, then the
   client must not make call B until it knows A has finished.
 
 I should have given more details, sorry.
 
 I am writing both the server and the client with twisted pb.
 The server (a game server) sends messages to four player clients.
 
 Say the game server sends messages A and B to a player client. 
 
 Is it granted that the player client always processes A first even
 if the internet routes the messages differently and B arrives
 first?

TCP guarantees in-order message delivery.  If you send A before B over
the same TCP connection, and A and B reach the client, then the client
will receive A before B.

Each Twisted process is single-threaded by default.

So if you use TCP, and keep the message processing code simple, then I
think you'll get messages processed in the order you expect.  I've never
noticed a problem with out-of-order messages in my PB game, anyway.

-- 
David Riptondrip...@ripton.net

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


Re: [Twisted-Python] order of remote requests

2009-12-29 Thread Wolfgang Rohdewald
On Tuesday 29 December 2009, David Ripton wrote:
 TCP guarantees in-order message delivery.  If you send A before B
  over the same TCP connection, and A and B reach the client, then
  the client will receive A before B.

Of course - now I wonder what made me think otherwise.

Thank you for your explanation! 


-- 
Wolfgang

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


Re: [Twisted-Python] order of remote requests

2009-12-29 Thread Andrew Bennetts
Wolfgang Rohdewald wrote:
[...]
 I should have given more details, sorry.
 
 I am writing both the server and the client with twisted pb.
 The server (a game server) sends messages to four player clients.
 
 Say the game server sends messages A and B to a player client. 
 
 Is it granted that the player client always processes A first even
 if the internet routes the messages differently and B arrives
 first?

A PB connection uses a single TCP connection.  TCP guarantees that the
bytes will arrive in order (or not at all), so the messages will arrive
at the client in the order the server sent them, assuming there is one
persistent PB connection between each client and the server (which seems
likely from your description).

So it is impossible for the internet to route the messages such that B
will arrive before A.

Neither PB nor TCP guarantee anything about when the recipient
“processes” those messages though, just that they will arrive in the
order they were sent.  For example consider if A and B arrive very close
together (in the same millisecond, say) and the client processes them by
dispatching to a thread pool, which might take 10s or even 100s of
milliseconds to fully process the message (and determine a reply, if
applicable)... then depending on the exact work required and exactly how
the OS schedules the threads, then B might be fully processed before A
is, even though A arrived first.

Apologies for such a pedantically precise and abstract answer, but what
exactly you mean when you say “processes” is a bit ambiguous.  I hope
this reply helps.

-Andrew.


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


Re: [Twisted-Python] twisted version of openid

2009-12-29 Thread Phil Christensen

On Dec 29, 2009, at 1:31 PM, Kevin Horn wrote:
On Tue, Dec 29, 2009 at 10:12 AM, Raj kumar  
k_r_a_j_ku...@yahoo.co.in wrote:

Hi,
Currently I'm having a server running under twisted. I'm planning to  
implement openid in my application. Is there any twisted version of  
openid api? I need some reference to go through openid examples.


Thanks in advance.

Raj.


Google is you friend: https://launchpad.net/txopenid

It may not suit your purposes exactly, but it seems like a good  
place to start.


txopenid is an identity provider for OpenID version 1.1. That is, it  
can provide credentials for sites that accept OpenID logins, based on  
data stored in a MySQL database.


It won't currently help you *accept* OpenID as an authentication  
mechanism, but it's a great provider, IMNSHO ;-) I use it as my  
identity provider, and so far it works well for my purposes. It also  
has been pleasantly stable the whole time I've been running it (at  
least as monitored by Nagios).


Also, it provides a number of utility functions that are essential to  
the OpenID spec which should make writing a consumer a bit easier  
(particularly in regards to hmac digest support and encoding integers  
into their big-endian two's complement as a binary string...ugh)...


Admittedly OpenID is at version 2.x these days, so I'm hoping soon to  
update the provider and/or write a consumer implementation. I'd like  
to think OpenID is finally starting to catch on...


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