Skip to content

Commit af49d44

Browse files
authored
Merge pull request #2062 from thomasgoirand/master
Python 3 compat
2 parents cdf15b9 + a22db37 commit af49d44

40 files changed

+126
-105
lines changed

contrib/spoolqueue/tasks.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
from __future__ import print_function
2+
13
from tasksconsumer import queueconsumer
24

35

46
@queueconsumer('fast', 4)
57
def fast_queue(arguments):
6-
print "fast", arguments
8+
print("fast", arguments)
79

810

911
@queueconsumer('slow')
1012
def slow_queue(arguments):
11-
print "foobar", arguments
13+
print("foobar", arguments)

contrib/spoolqueue/tasksconsumer.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from uwsgidecorators import spool
2-
import Queue
32
from threading import Thread
43

4+
from six.moves import queue
5+
56
queues = {}
67

78

@@ -10,7 +11,7 @@ class queueconsumer(object):
1011
def __init__(self, name, num=1, **kwargs):
1112
self.name = name
1213
self.num = num
13-
self.queue = Queue.Queue()
14+
self.queue = queue.Queue()
1415
self.threads = []
1516
self.func = None
1617
queues[self.name] = self
@@ -19,7 +20,7 @@ def __init__(self, name, num=1, **kwargs):
1920
def consumer(self):
2021
while True:
2122
req = self.queue.get()
22-
print req
23+
print(req)
2324
self.func(req)
2425
self.queue.task_done()
2526

contrib/uwsgi-cache-monitor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import print_function
2+
13
import mmap
24
import os
35
import struct

examples/bootstrap5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import uwsgi
22

3-
print uwsgi.extract("data://0")
3+
print(uwsgi.extract("data://0"))

examples/mjpeg_stream.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def application(env, start_response):
1717

1818
while 1:
1919
yield "Content-Type: image/jpeg\r\n\r\n"
20-
print subprocess.call('screencapture -t jpg -m -T 1 screenshot.jpg', shell=True)
20+
print(subprocess.call('screencapture -t jpg -m -T 1 screenshot.jpg', shell=True))
2121
f = open('screenshot.jpg')
2222
yield env['wsgi.file_wrapper'](f)
2323
yield "\r\n--%s\r\n" % boundary

examples/simple_app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ def ciao():
1010

1111
def ciao2():
1212
print("nuovo uwsgi_server")
13-
print os.getpid()
13+
print(os.getpid())
1414

1515
counter = 0
1616

1717
#if uwsgi.load_plugin(0, 'plugins/example/example_plugin.so', 'ciao'):
18-
# print "example plugin loaded"
18+
# print("example plugin loaded")
1919
#else:
20-
# print "unable to load example plugin"
20+
# print("unable to load example plugin")
2121

2222
#uwsgi.event_add(uwsgi.EVENT_FILE, "/tmp", ciao)
2323
#uwsgi.event_add(uwsgi.EVENT_DNSSD, "_uwsgi._tcp", ciao2)

examples/simple_app_wsgi2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from six.moves import range
12

23
def mygen(uri):
3-
for i in xrange(1, 100):
4+
for i in range(1, 100):
45
yield "ciao %s<br/>" % uri
56

67

examples/taskqueue.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import Queue
21
from threading import Thread
32
import uwsgi
43

4+
from six.moves import queue
5+
6+
57
CONSUMERS = 4
68

79

@@ -15,7 +17,7 @@ def consumer(q):
1517

1618
def spawn_consumers():
1719
global q
18-
q = Queue.Queue()
20+
q = queue.Queue()
1921
for i in range(CONSUMERS):
2022
t = Thread(target=consumer, args=(q,))
2123
t.daemon = True

examples/uwsgirouter.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ def application(env, start_response):
1111

1212
# has timed out ?
1313
if env['x-wsgiorg.fdevent.timeout']:
14-
print "connection timed out !!!"
14+
print("connection timed out !!!")
1515
uwsgi.close(fd)
1616
raise StopIteration
1717

1818
# connection refused ?
1919
if not uwsgi.is_connected(fd):
20-
print "unable to connect"
20+
print("unable to connect")
2121
uwsgi.close(fd)
2222
raise StopIteration
2323

@@ -42,7 +42,7 @@ def application(env, start_response):
4242
bufsize = min(cl, 4096)
4343
yield uwsgi.wait_fd_read(input, 30)
4444
if env['x-wsgiorg.fdevent.timeout']:
45-
print "connection timed out !!!"
45+
print("connection timed out !!!")
4646
uwsgi.close(fd)
4747
raise StopIteration
4848
body = uwsgi.recv(input, bufsize)
@@ -57,7 +57,7 @@ def application(env, start_response):
5757

5858
# has timed out ?
5959
if env['x-wsgiorg.fdevent.timeout']:
60-
print "connection timed out !!!"
60+
print("connection timed out !!!")
6161
uwsgi.close(fd)
6262
raise StopIteration
6363

@@ -68,7 +68,7 @@ def application(env, start_response):
6868
# wait for response
6969
yield uwsgi.wait_fd_read(fd, 30)
7070
if env['x-wsgiorg.fdevent.timeout']:
71-
print "connection timed out !!!"
71+
print("connection timed out !!!")
7272
uwsgi.close(fd)
7373
raise StopIteration
7474
data = uwsgi.recv(fd)

examples/uwsgirouter3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def application(e, s):
99
global current_node
1010

1111
nodes = uwsgi.cluster_nodes()
12-
print nodes
12+
print(nodes)
1313

1414
if len(nodes) == 0:
15-
print "no cluster node available"
15+
print("no cluster node available")
1616
raise StopIteration
1717

1818
if current_node >= len(nodes):

0 commit comments

Comments
 (0)