Comments (7)
Ah nice find, you can see that under the try except there is some code which attempts to shutdown the socket. Regarding the pull it might be cleaner if it called self.stop() unless you disagree?
from betfair.
I clearly wasn't thinking when I added that finally
block - the loop is only ever going to get executed once with that in there.
I agree about calling the stop
method instead.
I've changed the raises to just logging.error(...)
calls and then added self.stop()
.
I changed the test_read_loop_error
test to call _read_loop()
and then assert not self.betfair_stream._running
- not sure if this is the best way to test it?
If the raise is removed and changed to a logging.error
call, it means that exceptions.SocketError
is actually no longer used anywhere in the package; do you want to get rid of it?
When this PR gets merged, I'll update the logging PR to switch the naked logging.error
call to obtain a module logger and then use that.
from betfair.
I need an error to be raised if there is a timeout or another error or my framework will not know that there is an issue and the stream needs to be restarted / reconnect. I agree with the addition of self.stop() but I think an error has to be raised.
from betfair.
I think I misunderstood your reason for calling stop()
- I thought it was so that it would break out of the loop and call the socket cleanup code.
Clearly if the exception is still raised, it will never reach that cleanup code even after calling stop()
and having _running
set to False.
However, just calling stop()
before raise
will set _running
to False which will allow me to check the aliveness of the thread, and still throw the exception.
Shall I just create a new branch / PR and put that in there since there's a load of rubbish which isn't applicable now in this one?
from betfair.
Hmm you are right raising the error means the socket will never be cleaned unless the entire while loop is placed in a try/except and a finally with the stop + cleanup code but that doesn't seem very pythonic.
I think the logical thing to do is to move the clean up code into stop(), because the socket gets recreated during the start() process anyway.
from betfair.
Agreed, I think the socket cleanup code should go into stop()
.
from betfair.
I've redone the PR in #52
from betfair.
Related Issues (20)
- Betfair Exchange - Change of Minimum Stake - Multiple Currencies - 28th March 2022
- Max retries exceeded with url
- Batb odds not displaying when streaming HOT 2
- market_definition returns None HOT 3
- Add "modified" field to CricketIncident message
- get_account_statement missing 1 required positional argument: 'fullMarketName' HOT 1
- Question about JSON conversion HOT 1
- Cricket Scores API - New Release - Tuesday 25th October
- Streaming market book total_matched is different from polled total_matched HOT 1
- Serializing and Deserializing MarketBook to/from JSON loses market_definition
- No exchange prices available issues
- SSLV3_ALERT_HANDSHAKE_FAILURE HOT 1
- Session management on azure HOT 2
- Flumine seems stuck in orderstream handle_output HOT 2
- betfairlightweight.exceptions.SocketError: [Connect: 2]: Connection closed by server HOT 1
- Cancel Order single bet
- `ssl.wrap_socket` removed in python 3.12 HOT 3
- Add option to request 'additional data' on the getmarketcatalogue endpoint HOT 2
- [Feature Request] get additional data such as "broadcasts" and "matchInfo" of events returned in in_play_service
- I can see more event types(sports) on the Betfair official website when compared to the Betfair APIs. Is there any reason for this? HOT 13
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 betfair.