zhouyl / connectionpool Goto Github PK
View Code? Open in Web Editor NEWThread-safe connection pool
License: MIT License
Thread-safe connection pool
License: MIT License
I wanted to create an official conda package on conda-forge with the contents of my PR (#3). I'd like to use the same name you used on pip for continuity, but only if it's OK with you. I can build it from my fork or from yours if you accept the PR.
For reference, you can see the discussion here: conda-forge/staged-recipes#12676
Two related requests.
Is it possible to add a way of closing a connection on _destroy?
Is it possible to provide a way to close all connections in the pool?
I use the pool for FTP connections and they like to be closed (ftp.quit())
import ftplib
class FTPpool(ConnectionPool):
def _destroy(self, wrapped):
'''销毁一个连接'''
print(wrapped.connection.quit()) #ugly hack, added to close ftp conn
self._unwrapper(wrapped)
self._size -= 1
def close(self): #ugly hack to close the pool
_ids = [_id for _id, _ in self._ConnectionPool__wrappers.items()]
for _id in _ids:
self._destroy(self._ConnectionPool__wrappers[_id])
def ftp_conn(host,port)
ftp = ftplib.FTP()
ftp.connect(host, port)
ftp.login()
pool = FTPpool(
create=lambda: ftp_conn('127.0.0.1', 4242),
max_size=10,
max_usage=10,
idle=60,
ttl=60
)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.