Skip to content
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

pyflakes: undefined names, get_context() and main(), in multiprocessing #65189

Closed
vstinner opened this issue Mar 20, 2014 · 8 comments
Closed
Labels
type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

BPO 20990
Nosy @vstinner, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2014-03-25.21:47:19.515>
created_at = <Date 2014-03-20.08:00:03.849>
labels = ['type-bug']
title = 'pyflakes: undefined names, get_context() and main(), in multiprocessing'
updated_at = <Date 2014-03-25.21:47:19.513>
user = 'https://github.com/vstinner'

bugs.python.org fields:

activity = <Date 2014-03-25.21:47:19.513>
actor = 'sbt'
assignee = 'sbt'
closed = True
closed_date = <Date 2014-03-25.21:47:19.515>
closer = 'sbt'
components = []
creation = <Date 2014-03-20.08:00:03.849>
creator = 'vstinner'
dependencies = []
files = []
hgrepos = []
issue_num = 20990
keywords = []
message_count = 8.0
messages = ['214182', '214183', '214190', '214563', '214575', '214626', '214732', '214855']
nosy_count = 5.0
nosy_names = ['vstinner', 'jnoller', 'python-dev', 'sbt', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue20990'
versions = ['Python 3.4', 'Python 3.5']

@vstinner
Copy link
Member Author

Two warnings from pyflakes:

diff -r 72889bf8531d Lib/multiprocessing/spawn.py
--- a/Lib/multiprocessing/spawn.py      Tue Mar 18 13:21:29 2014 +0100
+++ b/Lib/multiprocessing/spawn.py      Wed Mar 19 11:49:24 2014 +0100
@@ -64,6 +64,7 @@ def freeze_support():
     Run code for process object if this in not the main process
     '''
     if is_forking(sys.argv):
+        # FIXME: main() is undefined
         main()
         sys.exit()
 
diff -r 72889bf8531d Lib/multiprocessing/synchronize.py
--- a/Lib/multiprocessing/synchronize.py        Tue Mar 18 13:21:29 2014 +0100
+++ b/Lib/multiprocessing/synchronize.py        Wed Mar 19 11:50:50 2014 +0100
@@ -51,7 +51,6 @@ class SemLock(object):
     _rand = tempfile._RandomNameSequence()
 
     def __init__(self, kind, value, maxvalue, *, ctx):
-        ctx = ctx or get_context()
         ctx = ctx.get_context()
         unlink_now = sys.platform == 'win32' or ctx._name == 'fork'
         for i in range(100):

@vstinner
Copy link
Member Author

Serhiy suggested (msg214136):

"Lib/multiprocessing/synchronize.py:
Add at the start of the file:
from . import get_context"

It looks like multiprocessing.get_context() exists, but I don't see how it is defined.

For main(), it should maybe be replaced with _main()?

@serhiy-storchaka
Copy link
Member

It looks like multiprocessing.get_context() exists, but I don't see how it
is defined.

It is defined by:

globals().update((name, getattr(context._default_context, name))
for name in context._default_context.__all__)

For main(), it should maybe be replaced with _main()?

_main() has different signature.

@sbt sbt mannequin self-assigned this Mar 20, 2014
@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 23, 2014

New changeset 619331c67638 by Richard Oudkerk in branch '3.4':
Issue bpo-20990: Fix issues found by pyflakes for multiprocessing.
http://hg.python.org/cpython/rev/619331c67638

@vstinner
Copy link
Member Author

Would it be possible to write a test?

Le dimanche 23 mars 2014, Roundup Robot <report@bugs.python.org> a écrit :

Roundup Robot added the comment:

New changeset 619331c67638 by Richard Oudkerk in branch '3.4':
Issue bpo-20990: Fix issues found by pyflakes for multiprocessing.
http://hg.python.org/cpython/rev/619331c67638

----------
nosy: +python-dev


Python tracker <report@bugs.python.org <javascript:;>>
<http://bugs.python.org/issue20990\>


@python-dev
Copy link
Mannequin

python-dev mannequin commented Mar 23, 2014

New changeset bb6377db0a9e by Richard Oudkerk in branch '3.4':
Issue bpo-20990: Correction for 619331c67638.
http://hg.python.org/cpython/rev/bb6377db0a9e

@vstinner
Copy link
Member Author

Can we close this issue? Or Richard wants to write a test?

@sbt
Copy link
Mannequin

sbt mannequin commented Mar 25, 2014

Testing the is_forking() requires cx_freeze or something similar, so it really cannot go in the test suite.

I have tested it manually (after spending too long trying to get cx_freeze to work with a source build).

It should be noted that on Unix freezing is currently only compatible with the default 'fork' start method.

@sbt sbt mannequin closed this as completed Mar 25, 2014
@sbt sbt mannequin added the type-bug An unexpected behavior, bug, or error label Mar 25, 2014
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants