-
Notifications
You must be signed in to change notification settings - Fork 86
TaskAdmin+fields(created_at,updated_at), ideomatic logger, TaskManager TaskManager __str__ try #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
30261b0
8831f1d
d402b4d
0e7a745
01fb783
69c482b
e56726c
2a01a5b
4ec1563
d6e26f5
4fd2266
5cb2550
588c027
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| /.tox | ||
| /.pytest_cache | ||
| /.python-version | ||
| /.idea/ | ||
| /benchmark*.svg | ||
| /build | ||
| /dist | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -12,24 +12,14 @@ | |||
| @admin.register(Task) | ||||
| class TaskAdmin(admin.ModelAdmin): | ||||
| exclude = ("message_data",) | ||||
| readonly_fields = ("message_details", "traceback", "status", "queue_name", "actor_name") | ||||
| list_display = ( | ||||
| "__str__", | ||||
| "status", | ||||
| "eta", | ||||
| "created_at", | ||||
| "updated_at", | ||||
| "queue_name", | ||||
| "actor_name", | ||||
| ) | ||||
| readonly_fields = ("message_details", "traceback", "status", "queue_name", "actor_name", "created_at", "updated_at") | ||||
| list_display = ("__str__", "status", "eta", "created_at", "updated_at", "queue_name", "actor_name") | ||||
|
ikvk marked this conversation as resolved.
Outdated
|
||||
| list_filter = ("status", "created_at", "queue_name", "actor_name") | ||||
| search_fields = ("actor_name",) | ||||
|
|
||||
| def eta(self, instance): | ||||
| timestamp = ( | ||||
| instance.message.options.get("eta", instance.message.message_timestamp) / 1000 | ||||
| ) | ||||
|
|
||||
| """Estimated time of arrival""" | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be the value of this docstring? It just deciphers a common-known abbreviation, which the function named after.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First time I took a few moments to decipher it, as I didn't meet her very often. I think it definitely won't hurt
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I would agree with @amureki on this. Lets remove it before merging.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you serious? How can the documentation line interfere?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I conducted a survey among 10 of my colleagues: "I know exactly what the abbreviation ETA stands for." Most of them are engineers. The result: 40% know for sure. I didn't think I'd have to defend the docstring either.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One more argument: By the way, is "Estimated time of arrival" the correct decoding of ETA? |
||||
| timestamp = (instance.message.options.get("eta", instance.message.message_timestamp) / 1000) | ||||
| # Django expects a timezone-aware datetime if USE_TZ is True, and a naive datetime in localtime otherwise. | ||||
| tz = timezone.utc if settings.USE_TZ else None | ||||
| return datetime.fromtimestamp(timestamp, tz=tz) | ||||
|
|
||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,4 +63,8 @@ def message(self): | |
| return Message.decode(bytes(self.message_data)) | ||
|
|
||
| def __str__(self): | ||
| return str(self.message) | ||
| try: | ||
| return str(self.message) | ||
| except Exception as e: | ||
| return f'Failed to display Task: {e}' | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this is interesting. Could you, please, provide some information regarding this?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, it was a long time ago, the log has already been cleared. I remember that it was for various reasons:
If I can find the info, I will definitely let you know. (or the dramatiq project)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you'd happen to find it, I am curious to see. 👍
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the broken data gets into the database, no matter how, then it actually breaks the admin web page. (we are dealing with bytes in BinaryField) This edit will avoid 500 errors if the data was suddenly broken. I don't understand your skepticism, security doesn't suffer, performance doesn't suffer either.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, if you felt scepticism in my comments - that was definitely not the intention. This code might not suffer from security or performance issues, but this is not the point. Plus, I think, if we just catch all exceptions here - we'd start ignoring them (as it is kinda handled already, right?), we could accidentally ignore important symptoms leading to this error. So if there is something wrong with bytes in And this is what I am missing here - I do not know the real case that this code change will solve, but it certainly introduces a different behaviour (even though it is a small one). I hope you could follow me here, and I am sorry, if you still would not agree with my thinking process here, but I truly believe this is only for the good of the project. Again, I am looking forward to understanding the underlying issue and let's try to solve it in its roots!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The key feature here is that the database cannot guarantee us the encodability of a BinaryField data. And I finally found the trace! |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ def rel(*xs): | |
|
|
||
|
|
||
| setup( | ||
| name="django_dramatiq", | ||
| name="django-dramatiq", | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Any reason to change the name of the project?? 🤔
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, Here is rules: This is not killer fature, but useful. If I saw such a MR for my library, I would also double-check everything 100 times.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I dont think this is the case, and its most likely due to the number of public repo dependents being less than 100..
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe so, I suggest you try, and if anything, you can roll back the changes in the minor release immediately after the release. |
||
| version=version, | ||
| description="A Django app for Dramatiq.", | ||
| long_description="Visit https://github.com/Bogdanp/django_dramatiq for more information.", | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.