Skip to content

Commit

Permalink
Merge pull request #111 from Azulinho/next_release
Browse files Browse the repository at this point in the history
FileLock is very slow
  • Loading branch information
Azulinho authored Sep 18, 2022
2 parents ae6bdbc + d321035 commit 863fcf3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import yaml
from binance.client import Client
from binance.exceptions import BinanceAPIException
from filelock import FileLock
from filelock import SoftFileLock
from lz4.frame import open as lz4open
from tenacity import retry, wait_exponential

Expand Down Expand Up @@ -489,7 +489,7 @@ def __init__(self, conn, config_file, config) -> None:
self.quit: bool = False
# define if we want to use MARKET or LIMIT orders
self.order_type: str = config.get("ORDER_TYPE", "MARKET")
self.binance_lock = FileLock("state/binance.lock", timeout=90)
self.binance_lock = SoftFileLock("state/binance.lock", timeout=90)

def extract_order_data(self, order_details, coin) -> Dict[str, Any]:
"""calculate average price and volume for a buy order"""
Expand Down
4 changes: 2 additions & 2 deletions lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests
import udatetime
from binance.client import Client
from filelock import FileLock
from filelock import SoftFileLock
from tenacity import retry, wait_exponential


Expand Down Expand Up @@ -65,7 +65,7 @@ def requests_with_backoff(query: str):
def cached_binance_client(access_key: str, secret_key: str) -> Client:
"""retry wrapper for binance client first call"""

lock = FileLock("state/binance.client.lockfile", timeout=10)
lock = SoftFileLock("state/binance.client.lockfile", timeout=10)
# when running automated-testing with multiple threads, we will hit
# api requests limits, this happens during the client initialization
# which mostly issues a ping. To avoid this when running multiple processes
Expand Down

0 comments on commit 863fcf3

Please sign in to comment.