earl / beanstalkc

A simple beanstalkd client library for Python
Apache License 2.0
458 stars 115 forks source link

Refactor to support delayed connections #62

Closed joncard1 closed 6 years ago

joncard1 commented 9 years ago

Could you refactor the constructor of beanstalkc.Connection to support delayed connections? Either make it conditional on a parameter "autoconnect" that defaults to True, or pull the initialization code into a method called "_initialize_connection".

The use case is a service that makes a large number of connections and re-connections to the server. Perhaps we should be maintaining a constant connection, but we are sub-classing beanstalkc.Connection so that it supports the Context Manager syntax (with beanstalkContext: etc.) and would like the connection to happen in the enter and the exit to handle the rollback of jobs that were created on exception. We are overriding the put method to cache the jobs created. We are forced to cut-and-paste the init to avoid connecting to the server on creation of the shared context object.

If you let me know how to submit code, I will submit code for review, if you would prefer. Thank you.

Rogdham commented 8 years ago

It seems that the part about the context manager syntax, plus the connection being into its own method is now implemented properly.

Could you look and see if that would be enough for you, and either close this issue or clarify what is left to be done?

joncard1 commented 6 years ago

I apologize; the company for whom I was requesting this shut down abruptly around the time this comment was added and I only just found it going through old issues looking for something. I don't really remember the issue and would be satisfied with closing it.