| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| FROM python:3.11-slim | ||
|
|
||
| # Install compilation dependencies | ||
| RUN apt-get update && apt-get install -y \ | ||
| gcc \ | ||
| pkg-config \ | ||
| libsystemd-dev \ | ||
| make \ | ||
| git \ | ||
| meson \ | ||
| jq \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN pip install --no-cache-dir wheel build | ||
|
|
||
| WORKDIR /src | ||
|
|
||
| # Fix git ownership issue | ||
| RUN git config --global --add safe.directory /src |
|
Comment thread
ggoldber marked this conversation as resolved.
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| services: | ||
| make: | ||
| build: . | ||
| volumes: | ||
| - .:/src | ||
| - ./build:/build | ||
| - ./dist:/dist | ||
| entrypoint: /usr/bin/make | ||
| command: all |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| # SPDX-License-Identifier: LGPL-2.1-or-later | ||
|
|
||
| option('docs', type : 'boolean', value : false) | ||
| option('journal_unlock_gil', type: 'integer', value: 1, description: 'unlock gil before sending log to journal') |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| Expand Up | @@ -8,6 +8,14 @@ | |
| #include "macro.h" | ||
| #include "pyutil.h" | ||
|
|
||
|
|
||
| #if defined(SD_JOURNAL_SENDV_UNLOCK_GIL) && (SD_JOURNAL_SENDV_UNLOCK_GIL == 1) | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityI think the prefix SD_ should be reserved by systemd proper.
Sorry, something went wrong.
All reactions
|
||
| #define JOURNAL_SENDV_UNLOCK_GIL 1 | ||
| #else | ||
| #define JOURNAL_SENDV_UNLOCK_GIL 0 | ||
| #endif | ||
|
|
||
|
|
||
| PyDoc_STRVAR(journal_sendv__doc__, | ||
| "sendv('FIELD=value', 'FIELD=value', ...) -> None\n\n" | ||
| "Send an entry to the journal." | ||
| Expand Down Expand Up | @@ -43,8 +51,14 @@ static PyObject* journal_sendv(PyObject *self _unused_, PyObject *args) { | |
| iov[i].iov_len = length; | ||
| } | ||
|
|
||
| #if (JOURNAL_SENDV_UNLOCK_GIL == 1) | ||
|
Comment thread
Copy link
Copy Markdown
Contributor
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityCan you comment on the thread safety of this? sd_journal objects (as in the C object, not the Python object), may only be accessed by a single thread at a time, see systemd/systemd#39199. I'm not sure this is ensured here, e.g. if two Python threads have access to the same (Python) journal object, sharing the same underlying sd_journal object one, both could try to write to the journal here and while in Python land this is is still ordered by the GIL, once both have released the GIL isn't it still racy? Also, how does this look with three-threading builds of Python?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityHi, thank you for the review. It seems like in no gil python these macros are still used, to yield thread execution context (I might be wrong, can dive deeper) In my case I have a single producer/consumer logging handler with QueueHandler/ QueueListener. If you have concerns, I can make it configurable (at runtime, in addition to compile time), wdyt?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
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. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNothing guarantees that all writes go through a logging handler. One can also call this function directly from different threads. This should either be made very explicit in the documentation or just be backed by a different lock
Sorry, something went wrong.
All reactions
|
||
| Py_BEGIN_ALLOW_THREADS | ||
| #endif | ||
| /* Send the iovector to the journal. */ | ||
| r = sd_journal_sendv(iov, argc); | ||
| #if (JOURNAL_SENDV_UNLOCK_GIL == 1) | ||
| Py_END_ALLOW_THREADS | ||
| #endif | ||
| if (r < 0) { | ||
| errno = -r; | ||
| PyErr_SetFromErrno(PyExc_OSError); | ||
| Expand Down Expand Up | @@ -111,6 +125,11 @@ PyMODINIT_FUNC PyInit__journal(void) { | |
| return NULL; | ||
| } | ||
|
|
||
| if (PyModule_AddIntConstant(m, "__sendv_unlock_gil__", JOURNAL_SENDV_UNLOCK_GIL)) { | ||
| Py_DECREF(m); | ||
| return NULL; | ||
| } | ||
|
|
||
| return m; | ||
| } | ||
| REENABLE_WARNING; | ||
| Back | FazBrowse Home | New Git URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityNew targets shouldn't go in the Makefile.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Qualitynp, will fix
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.