From 7a9f31b5eadd3918eff70fef296443e0c2a5f1ef Mon Sep 17 00:00:00 2001 From: Morty Space Date: Fri, 15 Oct 2021 18:36:09 +0300 Subject: [PATCH] Fixed eventloop bug when running on windows --- README.md | 1 + azure-pipelines.yml | 2 -- src/cryptocom/exchange/__init__.py | 2 +- src/cryptocom/exchange/api.py | 7 ++++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e0d40a1..f9536b8 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ Exchange original API docs: [https://exchange-docs.crypto.com](https://exchange- ### Changelog +- **0.9.1** - fixed Windows bug with asyncio event loop - **0.9.0** - updated coins, refactored wallet transactions - **0.8.1** - fixed coin name generation - **0.8** - fixed tests with updated coins diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 23d2643..bef7044 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,8 +29,6 @@ strategy: python.version: '3.8' Python39: python.version: '3.9' - Python310: - python.version: '3.10' steps: - checkout: self diff --git a/src/cryptocom/exchange/__init__.py b/src/cryptocom/exchange/__init__.py index e297527..0a7c50b 100644 --- a/src/cryptocom/exchange/__init__.py +++ b/src/cryptocom/exchange/__init__.py @@ -17,4 +17,4 @@ __all__ = [ 'ApiError', 'ApiProvider' ] -__version__ = '0.9' +__version__ = '0.9.1' diff --git a/src/cryptocom/exchange/api.py b/src/cryptocom/exchange/api.py index a11d63b..c2c0cf5 100644 --- a/src/cryptocom/exchange/api.py +++ b/src/cryptocom/exchange/api.py @@ -1,11 +1,11 @@ import os import json -import gzip import time import hmac import random import asyncio import hashlib +import platform from urllib.parse import urljoin @@ -33,6 +33,7 @@ class ApiProvider: self.retries = retries # NOTE: do not change this, due to crypto.com rate-limits + # TODO: add more strict settings, req/per second or milliseconds self.semaphore = asyncio.Semaphore(20) if not auth_required: @@ -44,6 +45,10 @@ class ApiProvider: if not self.api_key or not self.api_secret: raise ValueError('Provide api_key and api_secret') + if platform.system() == 'Windows': + asyncio.set_event_loop_policy( + asyncio.WindowsSelectorEventLoopPolicy()) + def read_keys_from_env(self): self.api_key = os.environ.get('CRYPTOCOM_API_KEY', '') if not self.api_key: