LittleDevMars / pyftpdlib

Automatically exported from code.google.com/p/pyftpdlib
Other
0 stars 0 forks source link

RuntimeError: maximum recursion depth exceeded #188

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
my ftp.py codes:

import sys 
import os
import time

from pyftpdlib import ftpserver

now = lambda: time.strftime("[%Y-%m-%d %H:%M:%S]")
f1 = open('ftpd.log', 'a')
f2 = open('ftpd.lines.log', 'a')
f3 = open('ftpd.error.log', 'a')

def standard_logger(msg):
    f1.write("%s %s\n" %(now(), msg))
    f1.flush()

def line_logger(msg):
    f2.write("%s %s\n" %(now(), msg))
    f2.flush()

def error_logger(msg):
    f3.write("%s %s\n" %(now(), msg))
    f3.flush()

def main(argv):
    ftpserver.log = standard_logger
    ftpserver.logline = line_logger
    ftpserver.logerror = error_logger

    if(len(argv)!=2):
        print ' order error! usage python p.py opt(w or h)  '
        exit()

    #opt(h : home or w : work)
    opt=argv[1]
    if(opt=='w'):
        ip="135.32.89.239"
    else:
        ip="192.168.1.101"

    authorizer = ftpserver.DummyAuthorizer()
    #authorizer.add_user("sjw", "sjw123", "G:\\", perm="elradfmw")
    authorizer.add_anonymous("G:\\")
    handler = ftpserver.FTPHandler
    handler.authorizer = authorizer
    address = (ip, 21)
    ftpd = ftpserver.FTPServer(address, handler)
    ftpd.serve_forever()

if __name__ == "__main__":
    main(sys.argv)
#=========================
run like this:
C:\>python ftp.py w

#=========error==========
Traceback (most recent call last):
  File "C:\Python27\lib\asyncore.py", line 91, in write
    obj.handle_write_event()
  File "C:\Python27\lib\asyncore.py", line 463, in handle_write_event
    self.handle_connect_event()
  File "C:\Python27\lib\asyncore.py", line 448, in handle_connect_event
    self.handle_connect()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 858, in handle_connect
    handler = self.cmd_channel.dtp_handler(self.socket, self.cmd_channel)
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 944, in __init__
    self.close()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 1137, in close
    asyncore.dispatcher.close(self)
  File "C:\Python27\lib\asyncore.py", line 403, in close
    self.socket.close()
  File "C:\Python27\lib\asyncore.py", line 412, in __getattr__
    retattr = getattr(self.socket, attr)
  ..................

  File "C:\Python27\lib\asyncore.py", line 412, in __getattr__
    retattr = getattr(self.socket, attr)
RuntimeError: maximum recursion depth exceeded

#==============================
with svn checkout pyftpdlib-read-only 901

#==============================
add this codes in my ftp.py , my ftp.py exit when error take place:

sys.setrecursionlimit(1000000)

Original issue reported on code.google.com by sjwhi8...@gmail.com on 15 Nov 2011 at 8:30

GoogleCodeExporter commented 9 years ago
Does this happen when the client connects?
Do you have the same problem if you use the 0.6.0 tarball instead of SVN r901?

Original comment by g.rodola on 15 Nov 2011 at 9:03

GoogleCodeExporter commented 9 years ago
This error is like happened in the client were connected the server, the 
transfer of data, I use the number of more connected to the client from the 
server to download transmission movies and other large files.

I use the 0.6 version happened the error, and so to change from SVN checkout 
the latest version test

At 2011-11-15 17:04:07,pyftpdlib@googlecode.com wrote:

Original comment by sjwhi8...@gmail.com on 15 Nov 2011 at 9:33

GoogleCodeExporter commented 9 years ago
So you have the error with both 0.6.0 tarball and latest SVN revision?
Is that correct?

Original comment by g.rodola on 15 Nov 2011 at 9:36

GoogleCodeExporter commented 9 years ago
yes, the error with both 0.6.0 tarball and latest SVN revision

Thank you concern about this problem, my English is very poor, forgive me ^-^.

At 2011-11-15 17:36:46,pyftpdlib@googlecode.com wrote:

Original comment by sjwhi8...@gmail.com on 15 Nov 2011 at 9:43

GoogleCodeExporter commented 9 years ago
Add the logs

Original comment by sjwhi8...@gmail.com on 15 Nov 2011 at 9:48

Attachments:

GoogleCodeExporter commented 9 years ago
Can you attach a unique log file including log, lines and errors?

Original comment by g.rodola on 15 Nov 2011 at 10:28

GoogleCodeExporter commented 9 years ago
Add the unique log file including log, lines and errors

Original comment by sjwhi8...@gmail.com on 16 Nov 2011 at 8:25

Attachments:

GoogleCodeExporter commented 9 years ago
Please try r902 and tell me if it fixes the problem.

Original comment by g.rodola on 16 Nov 2011 at 7:50

GoogleCodeExporter commented 9 years ago
r903 should also fix this error I see in your logs:

[2011-11-16 11:43:31] Traceback (most recent call last):
  File "C:\Python27\lib\asynchat.py", line 110, in handle_read
    data = self.recv (self.ac_in_buffer_size)
  File "C:\Python27\lib\asyncore.py", line 382, in recv
    data = self.socket.recv(buffer_size)
error: [Errno 10035] 

Original comment by g.rodola on 16 Nov 2011 at 8:08

GoogleCodeExporter commented 9 years ago
After testing, has solved "RuntimeError: maximum recursion depth exceeded" 
error, but there the following four errors, please help us to see.thanks!

========================== 1 error =================================
[2011-11-17 11:07:19] Traceback (most recent call last):
  File "C:\Python27\lib\asyncore.py", line 91, in write
    obj.handle_write_event()
  File "C:\Python27\lib\asyncore.py", line 463, in handle_write_event
    self.handle_connect_event()
  File "C:\Python27\lib\asyncore.py", line 448, in handle_connect_event
    self.handle_connect()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 860, in handle_connect
    self.cmd_channel._on_dtp_connection()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2321, in _on_dtp_connection
    if self._out_dtp_queue is not None:
  File "C:\Python27\lib\asyncore.py", line 415, in __getattr__
    %(self.__class__.__name__, attr))
AttributeError: FTPHandler instance has no attribute '_out_dtp_queue'

===========================  2 error 
============================================
[2011-11-17 11:11:18] Traceback (most recent call last):
  File "C:\Python27\lib\asyncore.py", line 83, in read
    obj.handle_read_event()
  File "C:\Python27\lib\asyncore.py", line 442, in handle_read_event
    self.handle_read()
  File "C:\Python27\lib\asynchat.py", line 158, in handle_read
    self.found_terminator()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2136, in found_terminator
    arg = self.fs.ftp2fs(arg or self.fs.cwd)
AttributeError: 'NoneType' object has no attribute 'ftp2fs'

===========================  3 error 
============================================

[2011-11-17 11:16:46] Traceback (most recent call last):
  File "C:\Python27\lib\asyncore.py", line 83, in read
    obj.handle_read_event()
  File "C:\Python27\lib\asyncore.py", line 442, in handle_read_event
    self.handle_read()
  File "C:\Python27\lib\asynchat.py", line 158, in handle_read
    self.found_terminator()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2168, in found_terminator
    self.process_command(cmd, arg, **kwargs)
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2177, in process_command
    method(*args, **kwargs)
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2713, in ftp_QUIT
    if self.data_channel:
  File "C:\Python27\lib\asyncore.py", line 415, in __getattr__
    %(self.__class__.__name__, attr))
AttributeError: FTPHandler instance has no attribute 'data_channel'

===========================  4 error 
============================================

[2011-11-17 11:20:06] Traceback (most recent call last):
  File "C:\Python27\lib\asynchat.py", line 110, in handle_read
    data = self.recv (self.ac_in_buffer_size)
  File "C:\Python27\lib\asyncore.py", line 382, in recv
    data = self.socket.recv(buffer_size)
error: [Errno 10035] 

Original comment by sjwhi8...@gmail.com on 17 Nov 2011 at 9:21

GoogleCodeExporter commented 9 years ago
Added, the above is based on svn r903 version of the test case.

Original comment by sjwhi8...@gmail.com on 17 Nov 2011 at 9:29

GoogleCodeExporter commented 9 years ago
Can you also attach a complete log (log +  logerror + logline) as you did 
before?
I need a context to better understand what's going on.

Original comment by g.rodola on 17 Nov 2011 at 4:58

GoogleCodeExporter commented 9 years ago
Also, it would help immensely if you could provide a way to reproduce these 
problems.
A step-to-step description, a script, anything.

Original comment by g.rodola on 17 Nov 2011 at 5:01

GoogleCodeExporter commented 9 years ago
Aattach the complete log (log +  logerror + logline)

Ftp with pyftpdlib to improve services, through multi-threaded downloading tool 
to download files when the error appeared in the log.

======== ftp.py =============
import sys 
import os
import time

from pyftpdlib import ftpserver

now = lambda: time.strftime("[%Y-%m-%d %H:%M:%S]")
#f1 = open('ftpd.log', 'a')
#f2 = open('ftpd.lines.log', 'a')
#f3 = open('ftpd.error.log', 'a')
f = open('ftpd.unique.log', 'a')

def standard_logger(msg):
    f.write("%s %s\n" %(now(), msg))
    f.flush()

def line_logger(msg):
    f.write("%s %s\n" %(now(), msg))
    f.flush()

def error_logger(msg):
    f.write("%s %s\n" %(now(), msg))
    f.flush()

def main(argv):
    ftpserver.log = standard_logger
    ftpserver.logline = line_logger
    ftpserver.logerror = error_logger

    if(len(argv)!=2):
        print ' order error! usage python p.py opt(w or h)  '
        exit()

    #opt(h : home or w : work)
    opt=argv[1]
    if(opt=='w'):
        ip="135.32.89.239"
    else:
        ip="192.168.1.101"

    authorizer = ftpserver.DummyAuthorizer()
    #authorizer.add_user("sjw", "sjw123", "G:\\", perm="elradfmw")
    authorizer.add_anonymous("G:\\")
    handler = ftpserver.FTPHandler
    handler.authorizer = authorizer
    address = (ip, 21)
    ftpd = ftpserver.FTPServer(address, handler)
    ftpd.serve_forever()

if __name__ == "__main__":
    main(sys.argv)
==========================================

(based on svn r903 version of the test case.)

Original comment by sjwhi8...@gmail.com on 18 Nov 2011 at 2:49

Attachments:

GoogleCodeExporter commented 9 years ago
I added some changes in r905 and r908.
Please try r908 and let me know how it goes.
As an extra: is it possible to see this thread-based script you're using?
I haven't been able to replicate any of your issues so far.

Original comment by g.rodola on 19 Nov 2011 at 6:19

GoogleCodeExporter commented 9 years ago
Tests with r908, still has the following two errors appear in the log.
In addition, multi-threaded downloading tool is not to write my own script, it 
is a download software program, in 
http://dl_dir.qq.com/invc/cyclone/QQDownload_Setup_38_702.exe download and 
install, then you can operate inside the screenshot to reproduce the error.
=================== 1 error ===============================
 Traceback (most recent call last):
  File "C:\Python27\lib\asyncore.py", line 83, in read
    obj.handle_read_event()
  File "C:\Python27\lib\asyncore.py", line 442, in handle_read_event
    self.handle_read()
  File "C:\Python27\lib\asynchat.py", line 158, in handle_read
    self.found_terminator()
  File "C:\Python27\lib\site-packages\pyftpdlib\ftpserver.py", line 2165, in found_terminator
    arg = self.fs.ftp2fs(arg or self.fs.cwd)
AttributeError: 'NoneType' object has no attribute 'ftp2fs'

========================== 2 error ======================================
[2011-11-20 11:40:17] Traceback (most recent call last):
  File "C:\Python27\lib\asynchat.py", line 110, in handle_read
    data = self.recv (self.ac_in_buffer_size)
  File "C:\Python27\lib\asyncore.py", line 382, in recv
    data = self.socket.recv(buffer_size)
error: [Errno 10035] 

Original comment by sjwhi8...@gmail.com on 21 Nov 2011 at 3:45

Attachments:

GoogleCodeExporter commented 9 years ago
As always, a "ftpd.unique.log" file would be a lot better. =)

Original comment by g.rodola on 23 Nov 2011 at 9:49

GoogleCodeExporter commented 9 years ago
Aattach the complete log.

Original comment by sjwhi8...@gmail.com on 24 Nov 2011 at 8:13

Attachments:

GoogleCodeExporter commented 9 years ago
Please try r919.

Original comment by g.rodola on 26 Nov 2011 at 6:22

GoogleCodeExporter commented 9 years ago
The same errors,testing with r922."-"

Original comment by sjwhi8...@gmail.com on 28 Nov 2011 at 11:47

Attachments:

GoogleCodeExporter commented 9 years ago
Don't if this could help, but I'm trying to create an FTP Server in windows, 
that catch all network interfaces and pass to pyftpdlib to listen.

The local client only can pass the username, after that it gets error.

Original comment by raf...@zamana.eti.br on 11 Feb 2012 at 12:55

Attachments: