Opened 5 years ago

Closed 3 months ago

#94 closed enhancement (wontfix)

asyncio

Reported by: ftputiluser Owned by: schwa
Priority: major Milestone:
Component: Library Version:
Keywords: Cc: requiredfield256@…

Description

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.

Change History (5)

comment:1 Changed 5 years ago by ftputiluser

Cc: requiredfield256@… added

comment:2 Changed 5 years ago by schwa

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?

comment:3 Changed 5 years ago by ftputiluser

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!

comment:4 Changed 5 years ago by schwa

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

comment:5 Changed 3 months ago by schwa

Resolution: wontfix
Status: newclosed

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.

Note: See TracTickets for help on using tickets.