Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions posthog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def alias(
def capture_exception(
exception: Optional[ExceptionArg] = None,
**kwargs: Unpack[OptionalCaptureArgs],
):
) -> Optional[str]:
"""
Capture exceptions that happen in your code.

Expand Down Expand Up @@ -1006,7 +1006,7 @@ def load_feature_flags():
return _proxy("load_feature_flags")


def flush():
def flush() -> None:
"""
Tell the client to flush all queued events.

Expand All @@ -1022,7 +1022,7 @@ def flush():
_proxy("flush")


def join():
def join() -> None:
"""
Block program until the client clears the queue. Used during program shutdown. You should use `shutdown()` directly in most cases.

Expand All @@ -1038,7 +1038,7 @@ def join():
_proxy("join")


def shutdown():
def shutdown() -> None:
"""
Flush all messages and cleanly shutdown the client.

Expand Down
9 changes: 5 additions & 4 deletions posthog/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ def capture_exception(
self,
exception: Optional[ExceptionArg],
**kwargs: Unpack[OptionalCaptureArgs],
):
) -> Optional[str]:
"""
Capture an exception for error tracking.

Expand Down Expand Up @@ -1196,6 +1196,7 @@ def capture_exception(
return res
except Exception as e:
self.log.exception(f"Failed to capture exception: {e}")
return None

@staticmethod
def _reinit_after_fork_weak(weak_self):
Expand Down Expand Up @@ -1346,7 +1347,7 @@ def _enqueue(self, msg, disable_geoip):
self.log.warning("analytics-python queue is full")
return None

def flush(self):
def flush(self) -> None:
"""
Force a flush from the internal queue to the server. Do not use directly, call `shutdown()` instead.

Expand All @@ -1362,7 +1363,7 @@ def flush(self):
# Note that this message may not be precise, because of threading.
self.log.debug("successfully flushed about %s items.", size)

def join(self):
def join(self) -> None:
"""
End the consumer thread once the queue is empty. Do not use directly, call `shutdown()` instead.

Expand All @@ -1386,7 +1387,7 @@ def join(self):
# Shutdown the cache provider (release locks, cleanup)
self._shutdown_flag_definition_cache_provider()

def shutdown(self):
def shutdown(self) -> None:
"""
Flush all messages and cleanly shutdown the client. Call this before the process ends in serverless environments to avoid data loss.

Expand Down