Fwd: ftplib sending data out of order

dieter dieter at handshake.de
Sat Jul 1 02:26:10 EDT 2017


Charles Wilt <charles.wilt at gmail.com> writes:
> ...
> First off, I'm not a python guy....but I use a set of python scripts
> created a few years ago by somebody else to transfer source between the SVN
> repo on my PC and an IBM i (aka AS/400) system.
>
> Recently, multiple developers, including me, have started having
> intermittent issues whereby the source gets sometimes gets scrambled during
> the send from PC to IBM i; and it seems to be happening more and more
> often.
>
> The python script hasn't been changed, and I've been running 2.7.12; though
> I've since tried upgrading to 2.7.13.
>
> I used wireshark to capture the FTP session and have confirmed that the
> data is leaving the PC in the incorrect order.  (screenshot attached)

The Python level is not concerned with the order of data packets.
In your case, it reads a block of data from the file and hands it
over to the communication channel. This channel is responsible
to split the data into packets, send them and reassemble them in
the correct order at the receiving side.


I see only two situations where the problem could reside at the Python
level -- both require multiple threads:

 * the file object is used concurrently by different threads
   (and thus, the thread doing the FTP does not see the file
   content in order)

 * two threads are using the same FTP connection concurrently.

It is unlikely that your case falls into such a situation.


To prove that the Python level is innocent, I would instrument the
"ftplib" code to protocol what is read from the file and what it handed
over to the communication channel.




More information about the Python-list mailing list