[issue21204] published examples don't work

2014-04-14 Thread jmaki

jmaki added the comment:

loewis, r.david.murray: Please proceed in terms of #3--The specific example 
does not work on Windows.  I am using python 2.7.6 on Windows 7.

Below is the failing message that happens immediately on startup, specifically, 
when hitting this line:
Process(target=serve_forever, args=(server,)).start()

Thank you for the attention.

- error message -
Traceback (most recent call last):
  File C:/Python27/httpthreadpool.py, line 75, in module
test()
  File C:/Python27/httpthreadpool.py, line 70, in test
runpool(ADDRESS, NUMBER_OF_PROCESSES)
  File C:/Python27/httpthreadpool.py, line 51, in runpool
Process(target=serve_forever, args=(server,)).start()
  File C:\Python27\lib\multiprocessing\process.py, line 130, in start
self._popen = Popen(self)
  File C:\Python27\lib\multiprocessing\forking.py, line 277, in __init__
dump(process_obj, to_child, HIGHEST_PROTOCOL)
  File C:\Python27\lib\multiprocessing\forking.py, line 199, in dump
ForkingPickler(file, protocol).dump(obj)
  File C:\Python27\lib\pickle.py, line 224, in dump
self.save(obj)
  File C:\Python27\lib\pickle.py, line 331, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python27\lib\pickle.py, line 419, in save_reduce
save(state)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python27\lib\pickle.py, line 681, in _batch_setitems
save(v)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 548, in save_tuple
save(element)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 725, in save_inst
save(stuff)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python27\lib\pickle.py, line 681, in _batch_setitems
save(v)
  File C:\Python27\lib\pickle.py, line 331, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python27\lib\pickle.py, line 419, in save_reduce
save(state)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python27\lib\pickle.py, line 681, in _batch_setitems
save(v)
  File C:\Python27\lib\pickle.py, line 331, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python27\lib\pickle.py, line 419, in save_reduce
save(state)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 649, in save_dict
self._batch_setitems(obj.iteritems())
  File C:\Python27\lib\pickle.py, line 681, in _batch_setitems
save(v)
  File C:\Python27\lib\pickle.py, line 331, in save
self.save_reduce(obj=obj, *rv)
  File C:\Python27\lib\pickle.py, line 396, in save_reduce
save(cls)
  File C:\Python27\lib\pickle.py, line 286, in save
f(self, obj) # Call unbound method with explicit self
  File C:\Python27\lib\pickle.py, line 748, in save_global
(obj, module, name))
PicklingError: Can't pickle type 'thread.lock': it's not found as thread.lock

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21204
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21204] multiprocessing example does not work on Windows

2014-04-14 Thread jmaki

jmaki added the comment:

Upon further investigation, this may be related to:
http://bugs.python.org/issue1378
However, it seems the issue is not checked-in to Windows release for 2.x?

Regards,
John

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21204
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21204] published examples don't work

2014-04-11 Thread jmaki

New submission from jmaki:

Would you consider putting examples given in official documentation as part of 
release testing?  e.g. (from official python.org documentation):
- snip -

An example of how a pool of worker processes can each run a 
SimpleHTTPServer.HttpServer instance while sharing a single listening socket.

#
# Example where a pool of http servers share a single listening socket
#
# On Windows this module depends on the ability to pickle a socket
# object so that the worker processes can inherit a copy of the server
# object.  (We import `multiprocessing.reduction` to enable this pickling.)
#
# Not sure if we should synchronize access to `socket.accept()` method by
# using a process-shared lock -- does not seem to be necessary.
#
# Copyright (c) 2006-2008, R Oudkerk
# All rights reserved.
#

import os
import sys

from multiprocessing import Process, current_process, freeze_support
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler

if sys.platform == 'win32':
import multiprocessing.reduction# make sockets pickable/inheritable


def note(format, *args):
sys.stderr.write('[%s]\t%s\n' % (current_process().name, format%args))


class RequestHandler(SimpleHTTPRequestHandler):
# we override log_message() to show which process is handling the request
def log_message(self, format, *args):
note(format, *args)

def serve_forever(server):
note('starting server')
try:
server.serve_forever()
except KeyboardInterrupt:
pass


def runpool(address, number_of_processes):
# create a single server object -- children will each inherit a copy
server = HTTPServer(address, RequestHandler)

# create child processes to act as workers
for i in range(number_of_processes-1):
Process(target=serve_forever, args=(server,)).start()

# main process also acts as a worker
serve_forever(server)


def test():
DIR = os.path.join(os.path.dirname(__file__), '..')
ADDRESS = ('localhost', 8000)
NUMBER_OF_PROCESSES = 4

print 'Serving at http://%s:%d using %d worker processes' % \
  (ADDRESS[0], ADDRESS[1], NUMBER_OF_PROCESSES)
print 'To exit press Ctrl-' + ['C', 'Break'][sys.platform=='win32']

os.chdir(DIR)
runpool(ADDRESS, NUMBER_OF_PROCESSES)


if __name__ == '__main__':
freeze_support()
test()
- snip -
does not work on windows...

Regards,
John

--
components: Cross-Build
messages: 215957
nosy: jmaki
priority: normal
severity: normal
status: open
title: published examples don't work
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21204
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com