Anders Kaseorg
a50eb2e809
mypy: Enable new error explicit-override.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-10-12 12:28:41 -07:00
Anders Kaseorg
4b19863065
test_timeout: Skip test_timeout_warn on Python 3.11 for coverage issue.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-05-18 11:52:22 -07:00
Anders Kaseorg
73c4da7974
ruff: Fix N818 exception name should be named with an Error suffix.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-11-17 16:52:00 -08:00
Anders Kaseorg
89e4233b68
timeout: Correct thread id type passed to PyThreadState_SetAsyncExc.
...
This type changed in Python 3.7:
https://github.com/python/cpython/pull/781
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-10-19 14:49:24 -07:00
Alex Vandiver
04159a674c
timeout: Minor comment cleanups.
...
We remove the StackOverflow link because it is now so dated as to be
irrelevant -- it does not use `self.ident`, and cargo-cults the return
value of PyThreadState_SetAsyncExc.
2022-04-07 17:26:01 -07:00
Alex Vandiver
3af2c8d9a3
timeout: Warn if the thread did not exit.
...
As noted in the docstring for this function, the timeout is
best-effort only -- if the thread is blocked in a syscall, it will not
service the exception until it returns. It can also choose to catch
and ignore the TimeoutExpired; in either case it will still be running
even after the `timeout()` function returns.
Raising a vare TimeoutExpired it still somewhat accurate, but obscures
that the backend thread may still be running along merrily. Notice
such cases, and log a warning about them.
2022-04-07 17:26:01 -07:00
Alex Vandiver
e714264756
timeout: Re-raise from where the TimeoutExpired hit the thread.
...
Having just thrown an exception into the thread, it is often useful to
know _what_ was the slow code that we interrupted. Raising a bare
TimeoutExpired here obscures that information, as any `exc_info` will
end there.
Examine the thread for any exception information, and use that to
re-raise. This exception information is not guaranteed to exist -- if
the thread didn't respond to the exception in time, or caught it, for
instance.
2022-04-07 17:26:01 -07:00
Alex Vandiver
85eeaf5f18
timeout: Remove cargo-culted and impossible-to-reach code block.
...
The quote in question originates in python/cpython@b8b6d0c2c6 , when
the code was added. However, the code stopped having that comment,
and was no longer able to return anything but 1 or 0, starting in
python/cpython@4643c2fda1 -- Python 2.5.
Remove the block.
2022-04-07 17:26:01 -07:00
Anders Kaseorg
b728727d9d
timeout: Remove unnecessary varargs support.
...
Mypy can check it this way.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-15 17:05:28 -08:00
Anders Kaseorg
6e4c3e41dc
python: Normalize quotes with Black.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Anders Kaseorg
11741543da
python: Reformat with Black, except quotes.
...
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-12 13:11:19 -08:00
Anders Kaseorg
365fe0b3d5
python: Sort imports with isort.
...
Fixes #2665 .
Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.
Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start. I expect this change will increase pressure for us to split
those files, which isn't a bad thing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00
Anders Kaseorg
fead14951c
python: Convert assignment type annotations to Python 3.6 style.
...
This commit was split by tabbott; this piece covers the vast majority
of files in Zulip, but excludes scripts/, tools/, and puppet/ to help
ensure we at least show the right error messages for Xenial systems.
We can likely further refine the remaining pieces with some testing.
Generated by com2ann, with whitespace fixes and various manual fixes
for runtime issues:
- invoiced_through: Optional[LicenseLedger] = models.ForeignKey(
+ invoiced_through: Optional["LicenseLedger"] = models.ForeignKey(
-_apns_client: Optional[APNsClient] = None
+_apns_client: Optional["APNsClient"] = None
- notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- signup_notifications_stream: Optional[Stream] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
+ signup_notifications_stream: Optional["Stream"] = models.ForeignKey('Stream', related_name='+', null=True, blank=True, on_delete=CASCADE)
- author: Optional[UserProfile] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
+ author: Optional["UserProfile"] = models.ForeignKey('UserProfile', blank=True, null=True, on_delete=CASCADE)
- bot_owner: Optional[UserProfile] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
+ bot_owner: Optional["UserProfile"] = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
- default_sending_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
- default_events_register_stream: Optional[Stream] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_sending_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
+ default_events_register_stream: Optional["Stream"] = models.ForeignKey('zerver.Stream', null=True, related_name='+', on_delete=CASCADE)
-descriptors_by_handler_id: Dict[int, ClientDescriptor] = {}
+descriptors_by_handler_id: Dict[int, "ClientDescriptor"] = {}
-worker_classes: Dict[str, Type[QueueProcessingWorker]] = {}
-queues: Dict[str, Dict[str, Type[QueueProcessingWorker]]] = {}
+worker_classes: Dict[str, Type["QueueProcessingWorker"]] = {}
+queues: Dict[str, Dict[str, Type["QueueProcessingWorker"]]] = {}
-AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional[LDAPSearch] = None
+AUTH_LDAP_REVERSE_EMAIL_SEARCH: Optional["LDAPSearch"] = None
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-22 11:02:32 -07:00
Anders Kaseorg
fff2d3958a
timeout: Use Python 3 raise syntax.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-09 16:42:13 -07:00
Anders Kaseorg
7ff9b22500
docs: Convert many http URLs to https.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-03-26 21:35:32 -07:00
neiljp (Neil Pilgrim)
9692a8572d
mypy: Add assertion in timeout.py.
2018-04-25 08:58:55 -07:00
rht
33b1a541d7
zerver/lib: Use python 3 syntax for typing.
...
With tweaks by tabbott to fix line spacing.
2017-11-18 16:09:04 -08:00
rht
691598a88b
py3: Remove "from six.moves import range".
...
This is no longer required, since in Python 3, this is what the range
built-in does.
2017-10-17 23:28:14 -07:00
rht
035ed93111
zerver/lib: remove `import six`.
2017-09-27 19:10:28 -07:00
rht
f43e54d352
zerver/lib: Remove absolute_import.
2017-09-27 10:00:39 -07:00
Aditya Bansal
b99d62d337
pep8: Add compliance with rule E261 timeout.py.
2017-06-04 15:06:29 +05:30
Nathan Miller
2311e169ec
mypy: Various strict-optional fixes in zerver.
2017-05-26 10:10:20 -07:00
Aditya Bansal
76d28a7cc7
pep8: Add compliance with rule E261 to timeout.py.
2017-05-07 23:21:50 -07:00
Eklavya Sharma
b7635db1e4
Replace 'type' with 'Type[BaseException]'.
...
This strengthens type checking and helps switch over to mypy 0.4.7.
2017-02-06 22:34:01 -08:00
Rafid Aslam
41bd88d5ed
pep8: Fix E301 pep8 violations.
...
Fix "E301: expected (1 or 2) blank line" pep8 violations.
2016-11-29 08:51:44 -08:00
Eklavya Sharma
6505cbf2bf
zerver/lib/timeout.py: Replace isAlive by is_alive.
...
In threading.Thread, isAlive has been removed in python 3.
We should use is_alive instead.
2016-07-06 11:49:48 -07:00
Eklavya Sharma
def8cd8e78
Annotate zerver/lib/timeout.py.
2016-06-29 10:41:01 -07:00
Varshit
4e1060076d
Purge 'from typing import *' from zerver/.
...
This is a partial implementation of #636 .
2016-04-07 14:07:07 -07:00
Tim Abbott
2059f650ab
Add PEP-484 type annotations to zerver/lib/.
2016-04-03 15:40:23 -07:00
Tim Abbott
f7878a61e1
Apply Python 3 futurize transform libmodernize.fixes.fix_xrange_six.
2015-11-01 09:35:06 -08:00
Tim Abbott
5ffb4deb8d
Apply Python 3 futurize transform libmodernize.fixes.fix_raise_six.
2015-11-01 09:35:05 -08:00
Tim Abbott
e111a2f9a5
[manual] Rename Django app from zephyr to zerver.
...
This needs to be deployed to both staging and prod at the same
off-peak time (and the schema migration run).
At the time it is deployed, we need to make a few changes directly in
the database:
(1) UPDATE django_content_type set app_label='zerver' where app_label='zephyr';
(2) UPDATE south_migrationhistory set app_name='zerver' where app_name='zephyr';
(imported from commit eb3fd719571740189514ef0b884738cb30df1320)
2013-08-06 07:39:36 -04:00