|
11 | 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | | -import asyncio |
| 14 | +import concurrent.futures |
15 | 15 | import enum |
16 | 16 | import logging |
17 | 17 | import os |
|
21 | 21 | from functools import wraps |
22 | 22 | from os.path import expanduser, join |
23 | 23 | from pathlib import Path |
24 | | -from typing import Dict, List, Optional, Tuple |
| 24 | +from typing import List, Optional, Tuple |
25 | 25 |
|
26 | 26 | import requests |
27 | 27 |
|
|
30 | 30 | USAGE_ENDPOINT = "https://usage.feast.dev" |
31 | 31 | _logger = logging.getLogger(__name__) |
32 | 32 |
|
| 33 | +executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) |
| 34 | + |
33 | 35 |
|
34 | 36 | @enum.unique |
35 | 37 | class UsageEvent(enum.Enum): |
@@ -90,14 +92,11 @@ def usage_id(self) -> Optional[str]: |
90 | 92 | return os.getenv("FEAST_FORCE_USAGE_UUID") |
91 | 93 | return self._usage_id |
92 | 94 |
|
93 | | - async def _send_request(self, json: Dict): |
94 | | - requests.post(USAGE_ENDPOINT, json=json) |
95 | | - |
96 | 95 | def _send_usage_request(self, json): |
97 | 96 | try: |
98 | | - task = asyncio.ensure_future(self._send_request(json)) |
| 97 | + future = executor.submit(requests.post, USAGE_ENDPOINT, json=json) |
99 | 98 | if self._is_test: |
100 | | - asyncio.wait(task) |
| 99 | + concurrent.futures.wait([future]) |
101 | 100 | except Exception as e: |
102 | 101 | if self._is_test: |
103 | 102 | raise e |
|
0 commit comments