-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add watchdog using a background thread to detect hung live execution (#…
…201) - This does not fix any hung bugs, but will make them more apparent - Causes and hanging could be stalled HTTPS requests, etc. - Hopefully fix the issues of APScheduler failing to fire `run_live` timed function correctly - Also replace `ganache` with `anvil` as `ganache` causes a lot of instability in the tests. Remove some @flaky as well.
- Loading branch information
Showing
28 changed files
with
602 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule web3-ethereum-defi
updated
5 files
+3 −3 | docs/source/tutorials/event-reader.rst | |
+3 −3 | docs/source/tutorials/live-price.rst | |
+4 −5 | docs/source/tutorials/live-swap.rst | |
+2 −2 | docs/source/tutorials/transfer.rst | |
+5 −0 | eth_defi/anvil.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export JSON_RPC_BINANCE="https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3" | ||
# export JSON_RPC_BINANCE="https://bsc-mainnet.nodereal.io/v1/64a9df0874fb4a93b9d0a3849de012d3" | ||
export JSON_RPC_BINANCE="https://intensive-lingering-dew.bsc.quiknode.pro/fb83ebe37b46b703d8f05c8e8fbda662aa7f9eeb/" | ||
export JSON_RPC_POLYGON="https://polygon-rpc.com" | ||
export TRADING_STRATEGY_API_KEY="secret-token:tradingstrategy-be8540bb501e2eccbdf6117ad65e0fac984ccfb3715d7a7b1046bcb8b1ebdb58" | ||
export BNB_CHAIN_JSON_RPC=$JSON_RPC_BINANCE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"""Multiprocess manager hang test. | ||
Good output (no multiprocessing.Manager): | ||
.. code-block:: text | ||
Doing subrouting launch_and_read_process | ||
poll() is None | ||
Terminating | ||
Got exit code -15 | ||
Got output Doing subrouting run_unkillable | ||
This is an example output | ||
The hang with Manager: | ||
.. code-block:: text | ||
Doing subrouting launch_and_read_process | ||
poll() is None | ||
Terminating | ||
Got exit code -15 | ||
""" | ||
import multiprocessing | ||
import subprocess | ||
import sys | ||
import time | ||
|
||
|
||
def launch_and_read_process(): | ||
proc = subprocess.Popen( | ||
[ | ||
"python", | ||
sys.argv[0], | ||
"run_unkillable" | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
# Give time for the process to run and print() | ||
time.sleep(3) | ||
|
||
status = proc.poll() | ||
print("poll() is", status) | ||
|
||
print("Terminating") | ||
assert proc.returncode is None | ||
proc.terminate() | ||
exit_code = proc.wait() | ||
print("Got exit code", exit_code) | ||
stdout, stderr = proc.communicate() | ||
print("Got output", stdout.decode("utf-8")) | ||
|
||
|
||
def run_unkillable(): | ||
# Disable manager creation to make the code run correctly | ||
manager = multiprocessing.Manager() | ||
d = manager.dict() | ||
d["foo"] = "bar" | ||
print("This is an example output", flush=True) | ||
time.sleep(999) | ||
|
||
|
||
def main(): | ||
mode = sys.argv[1] | ||
print("Doing subrouting", mode) | ||
func = globals().get(mode) | ||
func() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
This tests use Anvil to create a mainnet fork for testing. | ||
|
||
They are pretty heavy to run, so thus they are in a different folder. | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.