Skip to content

Release GIL prior to blocking (#412) #415

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

Merged
merged 2 commits into from
Jul 3, 2018
Merged

Release GIL prior to blocking (#412) #415

merged 2 commits into from
Jul 3, 2018

Conversation

rnpridgeon
Copy link
Contributor

No description provided.

@rnpridgeon rnpridgeon requested a review from edenhill July 3, 2018 02:29
@@ -595,8 +595,10 @@ static PyObject *Consumer_committed (Handle *self, PyObject *args,
if (!(c_parts = py_to_c_parts(plist)))
return NULL;

err = rd_kafka_committed(self->rk, c_parts,
tmout >= 0 ? (int)(tmout * 1000.0f) : -1);
Py_BEGIN_ALLOW_THREADS
Copy link
Contributor

@edenhill edenhill Jul 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know the Python docs advocate the use of this macro, but it is bad practice in C to design and use macros that end up with invalid C syntax (even though the expanded macro of course is correct).
This will mess up indentation.

Looking at the macro it should be safe to append a ; to each of those two lines, or even:

Py_BEGIN_ALLOW_THREADS {
...
} PY_BEGIN_END_ALLOW_THREADS;

But try with just ; first

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively I can use PyEval_SaveThread and PyEval_RestoreThread directly. Dealer's choice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if we are going to break convention anyway we might as well keep it consistent with the others. I'll go ahead and replace the macros with PyEval_SaveThread and PyEval_RestoreThread

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree, using the existing macros will make the code future-proof if additional calls are added in upcoming Python versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we can fix them all at the same time! #consistency

I see your point, I'll fix the syntax.

@rnpridgeon
Copy link
Contributor Author

@edenhill fixed

Copy link
Contributor

@edenhill edenhill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rnpridgeon rnpridgeon merged commit 6058401 into confluentinc:master Jul 3, 2018
@rnpridgeon rnpridgeon deleted the release_gil branch July 3, 2018 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy