Re: logging.SocketHandler connections



On Nov 20, 12:08 pm, oj <ojee...@xxxxxxxxx> wrote:
On Nov 19, 5:30 pm, Vinay Sajip <vinay_sa...@xxxxxxxxxxx> wrote:



On Nov 19, 10:27 am, oj <ojee...@xxxxxxxxx> wrote:

On Nov 16, 2:31 pm, Vinay Sajip <vinay_sa...@xxxxxxxxxxx> wrote:

Here is the server code. Pretty much directly copied from the example,
aside from not having the the handler loop forever, and queing the
records instead of dealing with the directly.

After further investigation, running the client with a long timeout,
without the server, so that every connection will fail, produces
results much closer to what I would expect. Connections attempted for
each message initially, but not for all of the later messages as the
retry time increases.

The point is kinda moot now, since I guess not closing the connection
is the 'right way' to do this, but I'm still interested in why I see
this behaviour when the server closes the connection.

I've investigated this and the issue appears not to be related to
closing connections. Your server code differs from the example in the
docs in one crucial way: there is a while loop which you have left out
in the handle() function, which deals with multipleloggingevents
received in one packet. Add this back in, and all 9 events are
received.

def handle(self):
while 1:
chunk = self.connection.recv(4)

if len(chunk) < 4:
break

slen = struct.unpack(">L", chunk)[0]
chunk = self.connection.recv(slen)

while len(chunk) < slen:
chunk = chunk + self.connection.recv(slen -
len(chunk))

obj = self.unPickle(chunk)
record =logging.makeLogRecord(obj)
queue_lock.acquire()
queue.insert(0, record)
queue_lock.release()

So it appears that due to buffering, 3 socket events are sent in each
packet sent over the wire. You were only processing the first of each
set of three, viz. nos. 0, 3, 6 and 9. Mystery solved, it appears!

Regards,

Vinay Sajip

I don't think buffering explains the behaviour I was seeing.

Can you confirm that if you add the while loop back in, all messages
are seen by the server? It worked for me.

Vinay Sajip
.



Relevant Pages

  • Re: Emergency! Too Busy A Connection!
    ... > a number of clients that need data from my Accessdatabase. ... The problem is that when the connection is retrieving data for ... > the loop, ... Server or another DBMS better suited to your environment and concurrent user ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Problem with OnReceive method
    ... > I' m developing a multithread application with a socket network ... > continuosly Receive in the thread socket loop. ... > this one start the server thread. ... when a connection arrived it start a new childthread and ...
    (microsoft.public.vc.mfc)
  • RE: Looping through tables
    ... On the Collection page of the ForEach Loop editor, ... of the appropriate Connection Manager to the value in the list. ... I need to move data from 15 tables from Server A to SQL Server 2005 ... database C, and then move data from 15 tables from Server B to SQL ...
    (microsoft.public.sqlserver.dts)
  • Re: LWP get but only get the first 25% then exit/stop_retrieveing
    ... read, at least, the first chunk, entirely, regardless of length. ... coming out of a server, but not an Apache server as prior discussed. ... Use of exit will break the connection, for your script, upon reading the first ... Without an exit, the read process will continue until the final chunk arrives. ...
    (perl.beginners)
  • Re: how can i read from a socket.getinputstream?!
    ... > seems that the program cannot run out of the while loop. ... Did you read my previous response? ... the server keeps the connection open by ...
    (comp.lang.java.programmer)