New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTP modue functions are not re-entrant,give odd exceptions #43196
Comments
If I define a class using the Thread and FTP moudles, For instance I get the following error when the The "213" reply is a response from the main process --------- from time import sleep
from threading import Thread
class ftpMachine(Thread, ftplib.FTP):
def __init__(self, svr, user, passwd):
Thread.__init__(self)
ftplib.FTP.__init__(self, svr, user, passwd)
def run(self):
for x in xrange(20):
output="Thread -"+str(self.nlst())[:30]
print output
sleep (0.0100)
def main():
aCon = ftpMachine("LocalFTP", "user", "")
aCon.start()
for x in xrange(20):
output = "Main -- " + str(aCon.size("File"))
print output
sleep (0.010) Workround: --------------- Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in
__bootstrap
self.run()
File "dualFTPIssue.py", line 17, in run
output = "Thread output " + str(self.nlst())[:30]
+" ..."
File "C:\Python24\lib\ftplib.py", line 448, in nlst
self.retrlines(cmd, files.append)
File "C:\Python24\lib\ftplib.py", line 396, in
retrlines
conn = self.transfercmd(cmd)
File "C:\Python24\lib\ftplib.py", line 345, in
transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Python24\lib\ftplib.py", line 321, in
ntransfercmd
host, port = self.makepasv()
File "C:\Python24\lib\ftplib.py", line 299, in
makepasv
host, port = parse227(self.sendcmd('PASV'))
File "C:\Python24\lib\ftplib.py", line 566, in
parse227
raise error_reply, resp
error_reply: 213 34603008 |
Logged In: YES IMHO this isn't a bug, your accessing a shared resource (the FTP connection) BTW. The fact that you subclass form thread and ftplib.FTP is immaterial, you |
Logged In: YES Unfortunately I can't start two instances of the FTP client Thanks for your attention in this matter. Closing this bug as my case is an unusual one. |
Logged In: YES I don't understand why you cannot use two connection resources. Are you Anyway, what you're doing right now is undefined behaviour. Unless explicitly BTW. I didn't close this bug, although I do understand why it was closed: the |
Logged In: YES I am running on a unit that limits the FTP connections to 4 For my current project, I have decided not to querry the |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: