[issue5877] Add a function for updating URL query parameters
New submission from Mart Sõmermaa m...@mrts.pri.ee: Proposal Add update_query_params() for updating or adding URL query parameters to urllib.parse and urlparse. Discussion -- Python-dev: http://mail.python.org/pipermail/python-dev/2009-April/088675.html Previously in Python-ideas: http://mail.python.org/pipermail/python-ideas/2009-March/003728.html The consensus seems to be that this is needed, opinions on how the API should look like vary. Behaviour - The following features were requested by different people: - ability to order parameters (by passing them in a ordered data structure) - plain behaviour that would keep the existing parameters as is and add passed in parameters, retaining duplicates - behaviour that removes duplicated values - dict.update()-like behaviour that would not allow duplicate keys (updating values for existing keys) - removal of existing parameters Implementation -- http://github.com/mrts/qparams/tree/master in particular http://github.com/mrts/qparams/blob/bf1b29ad46f9d848d5609de6de0bfac1200da310/qparams.py See the docstring in qparams.py for Currently, positional arguments are used to avoid name collisions in keyword arguments that were initially devised as the default, easy way to pass parameters. As the function signature has grown quite complex, this looks suboptimal. Also, the general sentiment was that the current three-valued logic for choosing key update strategy is also suboptimal. Instead, the strategy should be passed via a function and the strategies listed above should be provided in the module. Finally, removing keys is currently missing. It was proposed that passing foo=None would remove the parameter foo. Currently, None is used to mark parameters that do not take values, another marker is needed for that if removal is to be marked with None. Following on Nick Coghlan's suggestion in http://mail.python.org/pipermail/python-dev/2009-April/088866.html and considering the preference for a strategy function, the API could look as follows: def add_query_params(url, params, strategy=allow_dulicates, sep='') I.e. keyword arguments would not be supported and the default use would be as follows: add_query_params('foo', dict(bar='baz')) 'foo?bar=baz' -- components: Library (Lib) messages: 86802 nosy: mrts severity: normal status: open title: Add a function for updating URL query parameters type: feature request versions: Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5877 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5479] Add an easy way to provide total ordering now that __cmp__ is deprecated/gone
Mart Sõmermaa m...@mrts.pri.ee added the comment: This is the 2.6 version. What about the 3.0 version in http://docs.python.org/3.0/reference/datamodel.html#object.__lt__ needs to be updated? When functools.total_ordering (whether it lands in functools is open) lands that section should be amended in the lines of the following: There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__() so that the operators will behave as expected. However, given a class defining one or more ordering methods, `functools.total_ordering`_ class decorator can be used to fill in the rest. Please see the documentation of `functools.total_ordering`_ for further details. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5479 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5479] Add an easy way to provide total ordering now that __cmp__ is deprecated/gone
Mart Sõmermaa m...@mrts.pri.ee added the comment: Then why was this classified as a documentation issue? As the documentation section of http://docs.python.org/reference/datamodel.html#object.__lt__ needs to be updated as well to mark the eventual solution as the recommended easy way to provide total ordering. And why did Mart Sömmermaa submit it, and not Raymond? AFAICT, Raymond said he would propose something when it's ready (which I assume it currently isn't). Raymond's recipe at http://code.activestate.com/recipes/576685/ looks more or less complete, do you feel that his posting on the mailing list does not count as proposal? I submitted the feature request instead of him because I was the one who noticed the problem (as discussed on the mailing list) and felt responsible to report it here. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5479 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5479] Add an easy way to provide total ordering now that __cmp__ is deprecated/gone
New submission from Mart Sõmermaa m...@mrts.pri.ee: See http://mail.python.org/pipermail/python-dev/2009-March/087000.html and http://code.activestate.com/recipes/576685/ . -- assignee: georg.brandl components: Documentation, Library (Lib) messages: 83490 nosy: georg.brandl, mrts, rhettinger severity: normal status: open title: Add an easy way to provide total ordering now that __cmp__ is deprecated/gone type: feature request versions: Python 2.7, Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5479 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2090] __import__ with fromlist=[''] causes double initialization of modules
Mart Sõmermaa m...@mrts.pri.ee added the comment: A pointer for people who keep referring to this bug -- after discussions, the following idiom was selected as the official way to import modules by name in 2.x (as seen in latest 2.x docs http://docs.python.org/dev/library/functions.html#__import__ ). --- If you simply want to import a module (potentially within a package) by name, you can get it from sys.modules: import sys name = 'foo.bar.baz' __import__(name) module 'foo' from ... baz = sys.modules[name] baz module 'foo.bar.baz' from ... ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Ah, right you are. Attaching an initial alpha-quality patched shutil.py and a script to test the attack. Run the script by sourcing it with . test_issue4489.sh, not by executing (job control won't work in this case). Added file: http://bugs.python.org/file12482/shutil_patched.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Changes by Mart Sõmermaa m...@mrts.pri.ee: Added file: http://bugs.python.org/file12483/test_issue4489.sh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: And here's the diff so you can review what I was up to. Note that this does not yet fix the problem (although the logic looks about right), I have to examine the problem more thoroughly. -- keywords: +patch Added file: http://bugs.python.org/file12484/issue4489_first_attempt.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Aha, got it -- while removing /a/b/c/d, there's no easy way to detect that b or c has become a symlink. I.e. given directory tree a `-- b |-- c `-- d 1. os.rmdir('/a/b/c') succeeds 2. execution is suspended 3. '/a/b' is made a symlink to a path that contains 'd' 4. '/a/b/d' is neither a symlink, nor has it's inode been recorded, so os.rmdir('/a/b/d') succeeds I'm afraid the solution for the Perl bug is susceptible to the same problem. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: A blunt, ineffective solution would be to walk the tree before removing it and recording path : inode pairs in a dict on first pass and then checking that the inodes have not changed during removal on second pass. If no clever bulletproof fix emerges, perhaps this should be added as shutil.rmtree_safe (duh, API bloat...)? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Changes by Mart Sõmermaa m...@mrts.pri.ee: Removed file: http://bugs.python.org/file12483/test_issue4489.sh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Fixed a minor bug in test script and added Perl test as well. Perl with File-Path-2.07 passes the test. Added file: http://bugs.python.org/file12485/test_issue4489.sh ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Antoine, what if we add another function, rmtree_safe() that uses chdir() and document that it is protected from the race condition but may have the side effect of changing the current dir in threaded environment? ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Replying to previous comment: There's no way to do the check inode then remove sequence atomically. Right, although the attack window would be tiny, this is not a real solution. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: A shameless copy of the Perl fix for the bug http://bugs.debian.org/286922 looks like the evident solution. Somebody has to examine the fix though, I'm afraid I'm not currently able to do it. ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
Mart Sõmermaa m...@mrts.pri.ee added the comment: Mmmh, the problem with Perl's approach is that it changes the current working directory (calls to chdir()), which is process-specific and not thread-specific. Currently, no function in shutil changes the current working directory, which is a nice behaviour and should IMO be preserved. Using chdir() makes sense and it doesn't look like a too big problem to me: def rmtree(...): ... curdir = os.getcwd() try: call chdir() as required finally: try: os.chdir(curdir) except: warnings.warn(Unable to chdir to previous current dir) ... ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4457] __import__ documentation obsolete
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Brett, don't you think the import sys __import__('x.y.z') mod = sys.modules['x.y.z'] idiom should be recommended instead of/additionally to the lengthy getattr() one? ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4457 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4489] shutil.rmtree is vulnerable to a symlink attack
New submission from Mart Sõmermaa [EMAIL PROTECTED]: Race condition in the rmtree function in the shutils module allows local users to delete arbitrary files and directories via a symlink attack. See also http://bugs.debian.org/286922 Attack: --- # emulate removing /etc $ sudo cp -a /etc /root/etc/ $ sudo python2.6 for i in xrange(0, 5): ... with open(/root/etc/ + str(i), w) as f: ... f.write(0) ... $ ls /root/etc orig_list.txt $ mkdir /tmp/attack $ cp -a /root/etc/* /tmp/attack $ sudo python2.6 from shutil import rmtree rmtree('/tmp/attack') # press ctrl-z to suspend execution ^Z [1]+ Stopped sudo python2.6 $ mv /tmp/attack /tmp/dummy; ln -s /root/etc /tmp/attack $ fg sudo python2.6 Traceback (most recent call last): File stdin, line 1, in module File /usr/local/lib/python2.6/shutil.py, line 225, in rmtree onerror(os.rmdir, path, sys.exc_info()) File /usr/local/lib/python2.6/shutil.py, line 223, in rmtree os.rmdir(path) OSError: [Errno 20] Not a directory: '/tmp/attack' $ ls /root/etc new_list.txt $ diff -q orig_list.txt new_list.txt Files orig_list.txt and new_list.txt differ --- If the attack wasn't successful, /root/etc would not be modified and orig_list.txt and new_list.txt would be identical. -- components: Library (Lib) messages: 76753 nosy: mrts severity: normal status: open title: shutil.rmtree is vulnerable to a symlink attack type: security versions: Python 2.3, Python 2.4, Python 2.5, Python 2.6, Python 3.0 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4489 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4457] __import__ documentation obsolete
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Also, the examples that clarify __import__ behaviour by Nick Coghlan should be added: http://mail.python.org/pipermail/python-dev/2008-November/083735.html --- from foo.bar import baz stack top = __import__('foo.bar', globals(), locals(), ['baz'], -1) baz = stack top.baz When there are multiple names being imported or an 'as' clause is involved, I hope the reasons for doing it this way become more obvious: from foo.bar import baz, bob stack top = __import__('foo.bar', globals(), locals(), ['baz', 'bob'], -1) baz = stack top.baz bob = stack top.bob from foo.bar import baz as bob stack top = __import__('foo.bar', globals(), locals(), ['baz', 'bob'], -1) bob = stack top.baz --- And the winning idiom by Hrvoje Niksic for accessing module 'z', given name hierarchy 'x.y.z' should be documented as well: import sys __import__('x.y.z') mod = sys.modules['x.y.z'] -- nosy: +mrts ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4457 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Implement imp.import_module() instead. See http://mail.python.org/pipermail/python-dev/2008-November/083758.html Added file: http://bugs.python.org/file12147/imp_import_module.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Note that the hack described in http://bugs.python.org/issue2090 should be disabled once this gets integrated. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Given a module hierarchy string 'a.b.c', add an easy way to import tail module 'c'
Changes by Mart Sõmermaa [EMAIL PROTECTED]: -- components: -Interpreter Core title: Add an easy way to __import___ submodules - Given a module hierarchy string 'a.b.c', add an easy way to import tail module 'c' ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Corrections and clarifications: * I'd say labeling the patch naive and breaking things was misleading (there was a breakage that resulted from stale files with incorrect permissions from my previous build of Python 2.6; after a make distclean all tests passed as described above). The patch is correct and backwards-compatible in Python level, but it introduces a change in the C API: PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, - PyObject *globals, PyObject *locals, PyObject *fromlist, int level); + PyObject *globals, PyObject *locals, PyObject *fromlist, + int level, char submodule); * The patch was made against Python 2.6 release source. * The argument is named 'submodule' instead of 'toplevel' to avoid confusion with 'level'. ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: See also http://mail.python.org/pipermail/python-dev/2008-November/083727.html ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2090] __import__ with fromlist=[''] causes double initialization of modules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Just for reference, the simplest workaround is to use: modname = foo.bar.baz.baq mod = __import__(modname, {}, {}, [modname.rsplit(., 1)[-1]]) -- nosy: +mrts ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2090] __import__ with fromlist=[''] causes double initialization of modules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: See also http://bugs.python.org/issue4438 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue2090 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Attached is a naive proof-of-concept implementation (that breaks things, i.e. the real implementation should strive for better general compatibility), but works as expected: __import__('imprt.foo.foo', submodule=True) module 'imprt.foo.foo' from 'imprt/foo/foo.py' __import__('imprt.foo.foo', submodule=False) module 'imprt' from 'imprt/__init__.py' __import__('imprt.foo.foo') module 'imprt' from 'imprt/__init__.py' # Die on unexpected arguments like strings, lists etc to # avoid confusion __import__('imprt.foo.foo', submodule='z') Traceback (most recent call last): File stdin, line 1, in module TypeError: an integer is required -- keywords: +patch Added file: http://bugs.python.org/file12136/issue4438.diff ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
New submission from Mart Sõmermaa [EMAIL PROTECTED]: The need to dynamically import module foo given a module name string 'bar.baz.foo' is quite common. Quite often, the hack described in http://bugs.python.org/issue2090 is used (see e.g. the Google code results linked from the issue). Quoting Brett Cannon from the issue: I plan to add a much simpler API to the imp module for people to use directly so that these abuses don't continue. Although there are reasonable workarounds, let the current ticket be a remainder for Brett that his plan is indeed needed. Perhaps the easiest thing to do would be to add yet another argument, e.g. 'toplevel', to __import__, such that: __import__('imprt.foo.foo') # toplevel=True by default module 'imprt' from 'imprt/__init__.pyc' __import__('imprt.foo.foo', toplevel=False) module 'imprt.foo.foo' from 'imprt/foo/foo.pyc' The latter can currently be achieved by __import__('imprt.foo.foo', {}, {}, ['foo']) module 'imprt.foo.foo' from 'imprt/foo/foo.pyc' which is cumbersome if the module name is given in a string, resulting in unnecessarily complex code: modname = imprt.foo.foo __import__(modname, {}, {}, [modname.rsplit(., 1)[-1]]) module 'imprt.foo.foo' from 'imprt/foo/foo.pyc' -- components: Interpreter Core, Library (Lib) messages: 76460 nosy: mrts severity: normal status: open title: Add an easy way to __import___ submodules type: feature request versions: Python 2.7, Python 3.1 ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4438] Add an easy way to __import___ submodules
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Just a note that `make test` passes: 322 tests OK. 38 tests skipped: test_aepack test_al test_applesingle test_bsddb test_bsddb185 test_bsddb3 test_cd test_cl test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_curses test_dbm test_dl test_gl test_imageop test_imgfile test_kqueue test_linuxaudiodev test_macos test_macostools test_normalization test_ossaudiodev test_pep277 test_py3kwarn test_scriptpackages test_socketserver test_startfile test_sunaudiodev test_tcl test_timeout test_urllib2net test_urllibnet test_winreg test_winsound test_zipfile64 3 skips unexpected on linux2: test_tcl test_dbm test_bsddb ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue4438 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3518] multiprocessing: BaseManager.from_address documented but doesn't exist
Mart Sõmermaa [EMAIL PROTECTED] added the comment: I propose we add the following to that section as well. If you need to provide access to a queue from both local and remote processes, use `multiprocessing.Queue` in the server: from multiprocessing import Process, Queue from multiprocessing.managers import BaseManager class Worker(Process): ... def __init__(self, q): ... self.q = q ... super(Worker, self).__init__() ... def run(self): ... self.q.put('local hello') ... q = Queue() w = Worker(q) w.start() class QueueManager(BaseManager): pass ... QueueManager.register('getQueue', callable=lambda: q) m = QueueManager(address=('', 5), authkey='abracadabra') s = m.get_server() s.serve_forever() Use it in the client as shown above: from multiprocessing.managers import BaseManager class QueueManager(BaseManager): pass ... QueueManager.register('getQueue') m = QueueManager(address=('localhost', 5), authkey='abracadabra') m.connect() q = m.getQueue() q.get() 'local hello' q.put('remote hello') ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3518] multiprocessing: BaseManager.from_address documented but doesn't exist
Mart Sõmermaa [EMAIL PROTECTED] added the comment: The documentation should be amended as follows: Running the following commands creates a server for a single shared queue which remote clients can access: from multiprocessing.managers import BaseManager import Queue queue = Queue.Queue() class QueueManager(BaseManager): pass ... QueueManager.register('getQueue', callable=lambda:queue) m = QueueManager(address=('', 5), authkey='abracadabra') s = m.get_server() s.serve_forever() One client can access the server as follows: from multiprocessing.managers import BaseManager class QueueManager(BaseManager): pass ... QueueManager.register('getQueue') m = QueueManager(address=('localhost', 5), authkey='abracadabra') m.connect() q = m.getQueue() q.put('hello') Another client can also use it: from multiprocessing.managers import BaseManager class QueueManager(BaseManager): pass ... QueueManager.register('getQueue') m = QueueManager(address=('localhost', 5), authkey='abracadabra') m.connect() q = m.getQueue() q.get() -- nosy: +mrts ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3518] multiprocessing: BaseManager.from_address documented but doesn't exist
Mart Sõmermaa [EMAIL PROTECTED] added the comment: Also, it would be helpful to elaborate a bit more on: major: * how to implement a queue that is shared both locally and remotely (i.e. n local processes access the queue as well as m remote processes) minor: * blocking (assumption: q.get() blocks on socket.recv()) * timeout (assumption: the socket does not time out, e.g. q.get() blocks endlessly on socket.recv()) ___ Python tracker [EMAIL PROTECTED] http://bugs.python.org/issue3518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com