0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 04:12:23 +01:00

Update async events to clickhouse to use python 3.6 api (#1586)

This commit is contained in:
James Greenhill 2020-09-04 18:37:38 -07:00 committed by GitHub
parent 8e26357770
commit 1e905e2913
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from clickhouse_driver import Client as SyncClient # type: ignore
from posthog.settings import (
CLICKHOUSE,
CLICKHOUSE_ASYNC,
CLICKHOUSE_CA,
CLICKHOUSE_DATABASE,
CLICKHOUSE_HOST,
@ -16,7 +17,7 @@ from posthog.settings import (
TEST,
)
if not TEST:
if not TEST and CLICKHOUSE_ASYNC:
if PRIMARY_DB != CLICKHOUSE:
ch_client = Client(host="localhost")
else:
@ -31,7 +32,8 @@ if not TEST:
@async_to_sync
async def async_execute(query, args=None):
task = asyncio.create_task(ch_client.execute(query, args))
loop = asyncio.get_event_loop()
task = loop.create_task(ch_client.execute(query, args))
# we return this in case we want to cancel it
return task

View File

@ -116,6 +116,7 @@ CLICKHOUSE_SECURE = get_bool_from_env("CLICKHOUSE_SECURE", True)
CLICKHOUSE_VERIFY = get_bool_from_env("CLICKHOUSE_VERIFY", True)
CLICKHOUSE_REPLICATION = get_bool_from_env("CLICKHOUSE_REPLICATION", False)
CLICKHOUSE_ENABLE_STORAGE_POLICY = get_bool_from_env("CLICKHOUSE_ENABLE_STORAGE_POLICY", False)
CLICKHOUSE_ASYNC = get_bool_from_env("CLICKHOUSE_ASYNC", False)
_clickhouse_http_protocol = "http://"
_clickhouse_http_port = "8123"