Message 315452 - Python tracker

Message315452

Author Kaulkwappe
Recipients Kaulkwappe, christian.heimes, methane
Date 2018-04-18.13:45:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1524059121.01.0.682650639539.issue33307@psf.upfronthosting.co.za>
In-reply-to
Content
Thank you for your answer Christian. Indeed it seems a little more complex. As I worked with Non-TLS sockets before it looked like unexpected behaviour to me as on non-blocking sockets socket.send() would normally return 0 when no data was sent.

By the way this is the code I currently use:

Code:

	n = 0

	while 1:
		
		time.sleep(0.001)
		
		try:
		
			buffer = socket.recv(8192)
			
			if not buffer:
				break
			
		except OSError:
			print('{0}. try to send:'.format(n), len(blark), 'bytes')
			
			try:
				sent = socket.send(blark)
			except ssl.SSLWantWriteError:
				sent = 0
				n += 1
				
			print('Bytes sent:', sent)

		else:
			[...]
		
Result:

	1. try to send: 33554469 bytes
	Bytes sent: 0

	[...]

	137. try to send: 33554469 bytes
	Bytes sent: 0

	138. try to send: 33554469 bytes
	Bytes sent: 0

	139. try to send: 33554469 bytes
	Bytes sent: 33554469
History
Date User Action Args
2018-04-18 13:45:21Kaulkwappesetrecipients: + Kaulkwappe, christian.heimes, methane
2018-04-18 13:45:21Kaulkwappesetmessageid: <1524059121.01.0.682650639539.issue33307@psf.upfronthosting.co.za>
2018-04-18 13:45:21Kaulkwappelinkissue33307 messages
2018-04-18 13:45:20Kaulkwappecreate