Comments (4)
Very nice and clean example. It's impressive to see how easy gevent can be sneaked into synchronous code. I already thought of adding an issue for gevent support myself, basically to teach myself a bit of gevent, so you are preaching to the choir. But I do not have the time for this right now, and I wouldn't be using it in a serious real-life application. I also would have looked into trying to build a unified asynchronous client supporting both Twisted and gevent, but that's probably not the way gevent works. To cut a long story short, I'd be happy if you added gevent support to stompest in the way you see fit.
I find a solution with a stompest.gevent
the cleanest approach. This would be analogous to stompest.async
, meaning that stompest.gevent would be deployed as a separate PyPI package. This keeps the stompest
core self-consistent and lean, plain Python. Too many people would be scared off by big and sometimes problematic packages like Twisted or gevent. The setup should be straightforward if you follow along the lines of stompest.async. You basically have to copy and paste /src/async
to /src/gevent
and you are good to go. I am happy to help if you need it. I would prefer if all modules stayed in this repository for now, because I find it easier to apply upgrades across packages and have the documentation for all stompest packages centralized in one place.
If you don't feel like contributing right now, I would still be glad to add a section with your gevent example to the documentation.
from stompest.
I'm fine with the idea of requiring stompest.gevent
but a whole new package seems complete overkill for this.
The reality is that the only thing needed for gevent to work without monkey patching is for stompest.sync.transport
to use gevent.select
instead of select
for two lines in canRead and use gevent.socket
instead of socket
for one line inside of connect.
Everything else is 100% the same as sync. It feels very non-DRY to have an actual separate package.
Maybe if we modified the base of the sync code so we have an abstract transport that doesn't actually understand how to use socket or select. Then make sync subclass that transport with one using socket and select. And a stompest.gevent can make a transport subclass that uses gevent.socket and gevent.select.
from stompest.
We could add socket
and select
as factories to the StompFrameTransport
(analogous to the parser factory
which should be renamed, then), with the default implementations standard Python socket
and select
.
It does seem like overkill, but do you find it acceptable to import gevent
in the stompest core PyPI package without stating in its description that there is a dependency to gevent? If so, I'm fine with that. By the way, there is no violation of DRY in the code at all in either scenario, it's more a question of deployment and dependency handling.
from stompest.
This might not be as easy as I thought. stompest.sync.client.Stomp
uses time.sleep
which also needs to use a gevent version.
from stompest.
Related Issues (20)
- ipv6 support HOT 1
- stompest consumer is slow for activemq HOT 4
- How to config exclusive=true ? HOT 4
- Messages not recieving after queue is idle for some time HOT 1
- failover option 'startupMaxReconnectAttempts' default value should be -1
- Support for asyncio HOT 2
- Asynch examples on ActiveMQ - Artemis HOT 1
- support SSL client auth in stompest.async HOT 5
- Exception <class 'select.error'>: (4, 'Interrupted system call') after upgrading stompest HOT 4
- stompest.async will be unusable on python 3.7+ HOT 10
- receiveFrame does not accept a timeout parameter HOT 3
- Thread-unsafe issue if we set ack=True in SubscriptionListener HOT 3
- How to dynamically increase the number of consumers HOT 1
- Invalid SUBSCRIBE format HOT 2
- StompFrame and StompHeartBeat __str__ method returns bytes in Python 3
- failover doesn't seem to be working HOT 1
- how to get JMSXDeliveryCount in the stomp frame HOT 1
- When use version=1.2, the consumer stop to connect on topic
- collections.MutableMapping is not available in Python 3.10 HOT 7
- STOMP over websocket
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stompest.