diff options
| author | 2019-02-25 10:36:17 +0000 | |
|---|---|---|
| committer | 2019-02-25 10:36:17 +0000 | |
| commit | d627ed49e22ba9c57e50cd6de748a9f26fc03720 (patch) | |
| tree | 3ca7f6397b2108d620314a849402c566e5dfc79c /src/utils/__init__.py | |
| parent | Minor code stylisation in imgur.py (diff) | |
| signature | ||
Pull "is main thread" logic out to utils, force Database to be accessed on main
thread
Diffstat (limited to 'src/utils/__init__.py')
| -rw-r--r-- | src/utils/__init__.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/utils/__init__.py b/src/utils/__init__.py index 609b0eaa..44ba4587 100644 --- a/src/utils/__init__.py +++ b/src/utils/__init__.py @@ -1,4 +1,4 @@ -import datetime, decimal, enum, io, ipaddress, re, typing +import datetime, decimal, enum, io, ipaddress, re, threading, typing from src.utils import cli, consts, irc, http, parse, security class Direction(enum.Enum): @@ -199,3 +199,6 @@ def is_ip(s: str) -> bool: except ValueError: return False return True + +def is_main_thread() -> bool: + return threading.current_thread() is threading.main_thread() |
