[Pythonmac-SIG] Re: Rumor: test_socket and test_email don't work on OS9.
Bob Heeter
rfheeter@speakeasy.net
Sun, 3 Feb 2002 11:09:34 -0800
Perhaps a true expert could say something about when GUSI and/or Python
is likely to be fully fixed, and if there are any ways that those of us
in the user community could help?
Meanwhiles, here's a user-level perspective for Keith:
>Can anyone confirm a positive experience for using the sockets modules
>and email modules under OS9. What exact version do you have?
I'm running Python 2.1.1 on OS9.1 (original 250 MHz G3 powerbook built on
the 3400 chassis) and OS9.2.2 (G4 desktop, 733 MHz, vintage November 2001).
With Python 2.1.1, I've had some mixed experiences with sockets used by
ftplib and smtplib, but aside from a few problems the overall behavior
is not bad. I previously ran Python 1.5.2 for over a year without any
real problems (but without all the new features of the newer Pythons).
With regard to Python 2.1.1: Based on past list discussions, it seems
like the main problem is in the underlying (and relatively new) GUSI2
socket library which goes into Python. The older Python
internet-support modules expect different socket behavior than
GUSI2 is now providing. However, the problems are generally solvable
with a bit of work. I don't believe the newer Pythons have fixed them yet.
However, until I started using Python 2.1.1 I didn't even need to know
what a socket was, and if you aren't willing to fiddle with the libraries
a little, Python *might* give you some headaches.
For instance, here on my systems, ftplib.py in 2.1.1 would sometimes
cough up "socket not connected" errors when downloading files,
apparently because it has trouble telling when all the data has been
received. When I ran into this it was very frustrating, but with a few
hours of reviewing the list discussions and a bit of hacking
around, I got a workaround that was good enough for my purposes:
>From old ftplib.retrbinary:
while 1:
data = conn.recv(blocksize)
if not data:
break
callback(data)
conn.close()
My hack goes like this:
while 1:
data = ""
try:
data = conn.recv(blocksize)
except:
pass # (I have the program warn me when it gets here)
if not len(data):
break
else:
callback(data)
try:
conn.close()
except:
pass # (I have the program warn me when it gets here)
I'm sure someone with more experience can do better, but this works so far.
Also, I've been having some minor trouble with smtplib.
The module works, but right now it is really slow in connecting
to the mailserver to send a single message. I recently changed my local
network configuration (adding an AirPort2 between my cable modem
and my local hub), and it is now taking over 20 seconds (on the newer G4)
to 50 seconds (on the older G3) for smtplib.SMTP to connect to my ISP's
email server and send a single message. Previously, with the same
Python and MacOS, the same task took at most a few seconds.
(Subsequent messages using the same link transmit very quickly, though.)
What puzzles me is that this problem only affects Python; all my
regular Internet software works the same as it always did!
And if the problem was purely network-related, I wouldn't expect
the speed to depend so strongly on which machine I was using.
So I suspect there's something amiss inside smtplib or the libraries
it calls, but I haven't sorted out where the problem occurs yet.
There are also reports of issues with urllib and some of the other internet
libraries, but I haven't investigated them since I don't need them.
But the ftplib and smtplib interfaces are critical for what I am doing,
which is to run a small multiplayer online turn-based game as a hobby.
-- Bob
Bob Heeter
Livermore, California