Skip to content

Commit fc49dfc

Browse files
committed
Fix async submission
Signed-off-by: Danny Chiao <danny@tecton.ai>
1 parent a6c9cc8 commit fc49dfc

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎sdk/python/feast/usage.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import asyncio
14+
import concurrent.futures
1515
import enum
1616
import logging
1717
import os
@@ -21,7 +21,7 @@
2121
from functools import wraps
2222
from os.path import expanduser, join
2323
from pathlib import Path
24-
from typing import Dict, List, Optional, Tuple
24+
from typing import List, Optional, Tuple
2525

2626
import requests
2727

@@ -30,6 +30,8 @@
3030
USAGE_ENDPOINT = "https://usage.feast.dev"
3131
_logger = logging.getLogger(__name__)
3232

33+
executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
34+
3335

3436
@enum.unique
3537
class UsageEvent(enum.Enum):
@@ -90,14 +92,11 @@ def usage_id(self) -> Optional[str]:
9092
return os.getenv("FEAST_FORCE_USAGE_UUID")
9193
return self._usage_id
9294

93-
async def _send_request(self, json: Dict):
94-
requests.post(USAGE_ENDPOINT, json=json)
95-
9695
def _send_usage_request(self, json):
9796
try:
98-
task = asyncio.ensure_future(self._send_request(json))
97+
future = executor.submit(requests.post, USAGE_ENDPOINT, json=json)
9998
if self._is_test:
100-
asyncio.wait(task)
99+
concurrent.futures.wait([future])
101100
except Exception as e:
102101
if self._is_test:
103102
raise e

0 commit comments

Comments
 (0)