pydw

Check-in [4f9e162437]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enable exception handling. Set up to actually break from one client and start serving the next. Add ^C handler so we can cleanly exit.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:4f9e162437aa26f43e91e1181fd67c3b981d4552b3a8edb0bd0bee01cdedde9a
User & Date: ajv-899-334-8894@vsta.org 2016-07-16 02:14:43
Context
2016-07-16
19:58
comment from "beretta42" on Github, dw_init response might be better set to 0, not echoing back client's value. Leaf check-in: c424043861 user: ajv-899-334-8894@vsta.org tags: master, trunk
02:14
Enable exception handling. Set up to actually break from one client and start serving the next. Add ^C handler so we can cleanly exit. check-in: 4f9e162437 user: ajv-899-334-8894@vsta.org tags: master, trunk
2016-07-15
22:41
Cleanup (close writable disks) and exit on interrupt check-in: 93c183e96a user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to dw.py.

23
24
25
26
27
28
29


30
31
32
33
34
35
36
...
202
203
204
205
206
207
208

209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
	self.conn = conn

    # Receive, waiting if needed
    def recv(self, count):
	res = ""
	while count > 0:
	    buf = self.conn.recv(count)


	    res += buf
	    count -= len(buf)
	    if count > 0:
		# Hold off a bit for client to fill pipe
		# time.sleep(0.1)
		pass

................................................................................
    s.listen(5)

    # We want to fclose() all our writable devices before leaving
    signal.signal(signal.SIGINT, cleanexit)

    # Bring it
    while True:

	conn,tup = s.accept()
	print "DW client", tup

	# Talk to them
	# (TBD if we need multiple threads of service.)
	serve(NetIO(conn))
	try:
	    # serve(conn)
	    pass
	except:
	    print "DW connection abort"
	    try:
		conn.close()
	    except:
		pass







>
>







 







>





<

|
<






23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
204
205
206
207
208
209
210
211
212
213
214
215
216

217
218

219
220
221
222
223
224
	self.conn = conn

    # Receive, waiting if needed
    def recv(self, count):
	res = ""
	while count > 0:
	    buf = self.conn.recv(count)
	    if not buf:
		raise Exception, "Connection closed"
	    res += buf
	    count -= len(buf)
	    if count > 0:
		# Hold off a bit for client to fill pipe
		# time.sleep(0.1)
		pass

................................................................................
    s.listen(5)

    # We want to fclose() all our writable devices before leaving
    signal.signal(signal.SIGINT, cleanexit)

    # Bring it
    while True:
	print "DW waiting for client..."
	conn,tup = s.accept()
	print "DW client", tup

	# Talk to them
	# (TBD if we need multiple threads of service.)

	try:
	    serve(NetIO(conn))

	except:
	    print "DW connection abort"
	    try:
		conn.close()
	    except:
		pass