~sschwarzer/ftputil#94: 
asyncio

Dear Stefan, I'm looking for an asyncio-friendly FTP client and have yet to find one. Any interest in doing an ftputil implementation using asyncio? Thanks for your consideration and best wishes.

Status
RESOLVED WONT_FIX
Submitter
ftputiluser (unverified)
Assigned to
No-one
Submitted
9 years ago
Updated
9 years ago
Labels
enhancement library

schwa (unverified) 9 years ago · edit

Thanks for your friendly request. :-)

I think asyncio compatibility would be a good feature to have. There's definitely interest on my side.

On the other hand, ftputil uses ftplib.FTP (or compatible APIs) under the hood, and those are synchronous. I guess there are still ways to make this work somehow, maybe by using threads.

To tell if or how I could do it I'd need to look more into asyncio, which I'm planning to do anyway, not only for ftputil.

Is your question "just" out of interest or do you have a concrete use case in mind? How important is the feature for you right now and in the near future?

How much experience do you have with asyncio? Would you mind discussing a design with me if I come up with one? Did you even already look at the ftputil code and have ideas?

ftputiluser (unverified) 9 years ago · edit

Thanks for the quick and attentive reply, Stefan. My use case turned out to be very simple, and was satisfied by a few basic calls to ftplib directly, so I didn't end up needing ftputil after all.

I ended up using ​loop.run_in_executor (as ​recommended by the docs) to handle the blocking ftplib calls in my non-blocking code. However, much like the 3rd-party ​aiohttp fills the need for an asyncio-based http library, a 3rd-party "aioftp" library should exist to fill the need for an asyncio-based ftp library, but unfortunately none yet exists. If you or anyone else in the ftputil community is interested in implementing one, I bet it'd be a valuable contribution.

In case you're interested, ​http://asyncio.org might provide some more useful resources.

Thanks again!

schwa (unverified) 9 years ago · edit

Thanks a lot for the links. Especially ​http://asyncio.org seems to be useful to learn a lot. :-)

schwa (unverified) 4 years ago · edit

As mentioned in my comment, adding asyncio support to ftputil would hardly be possibly while relying on ftplib. Running ftputil operations in extra threads would be a workaround to be able to use ftputil in an asyncio event loop, but it wouldn't help with respect to the motivation of asyncio, i. e. not needing threads and their overhead for many connections.

The only motivation for asyncio with ftputil's underlying design, from my point of view, would be to make it be able to run ftputil operations in an asyncio event loop. I'm currently not planning an enhancement for this, but I may reconsider it if there's demand (e. g. expressed in this ticket). Therefore, I close this ticket for now.

Register here or Log in to comment, or comment via email.