Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
55e32bb7
Commit
55e32bb7
authored
Sep 15, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wsgi: add --pool option to command line script
parent
e81637eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
12 deletions
+15
-12
gevent/wsgi.py
gevent/wsgi.py
+15
-12
No files found.
gevent/wsgi.py
View file @
55e32bb7
...
@@ -204,26 +204,29 @@ def extract_application(filename):
...
@@ -204,26 +204,29 @@ def extract_application(filename):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
USAGE
=
'''python -m gevent.wsgi [options] /path/to/myapp.wsgi
Where /path/to/myapp.wsgi is a Python script that defines "application" callable.'''
import
optparse
import
optparse
parser
=
optparse
.
OptionParser
()
parser
=
optparse
.
OptionParser
(
USAGE
)
parser
.
add_option
(
'-p'
,
'--port'
,
default
=
'8080'
,
type
=
'int'
)
parser
.
add_option
(
'-p'
,
'--port'
,
default
=
'8080'
,
type
=
'int'
,
help
=
'Set listening port (default is 8080)'
)
parser
.
add_option
(
'--interface'
,
default
=
'127.0.0.1'
)
parser
.
add_option
(
'-i'
,
'--interface'
,
metavar
=
'IP'
,
default
=
'127.0.0.1'
,
help
=
'Set listening interface (default is 127.0.0.1)'
)
parser
.
add_option
(
'--no-spawn'
,
dest
=
'spawn'
,
default
=
True
,
action
=
'store_false'
)
parser
.
add_option
(
'--pool'
,
metavar
=
'SIZE'
,
dest
=
'spawn'
,
type
=
'int'
,
help
=
'Maximum number of concurrent connections'
)
parser
.
add_option
(
'--no-spawn'
,
action
=
'store_true'
,
help
=
'Do not spawn greenlets (no blocking calls)'
)
options
,
args
=
parser
.
parse_args
()
options
,
args
=
parser
.
parse_args
()
if
options
.
no_spawn
is
not
None
and
options
.
spawn
is
not
None
:
sys
.
exit
(
'Please specify either --pool or --no-spawn but not both'
)
if
options
.
no_spawn
:
options
.
spawn
=
None
elif
options
.
spawn
is
None
:
options
.
spawn
=
'default'
if
len
(
args
)
==
1
:
if
len
(
args
)
==
1
:
filename
=
args
[
0
]
filename
=
args
[
0
]
try
:
try
:
application
=
extract_application
(
filename
)
application
=
extract_application
(
filename
)
except
AttributeError
:
except
AttributeError
:
sys
.
exit
(
"Could not find application in %s"
%
filename
)
sys
.
exit
(
"Could not find application in %s"
%
filename
)
if
options
.
spawn
:
server
=
WSGIServer
((
options
.
interface
,
options
.
port
),
application
,
spawn
=
options
.
spawn
)
spawn
=
'default'
else
:
spawn
=
None
server
=
WSGIServer
((
options
.
interface
,
options
.
port
),
application
,
spawn
=
spawn
)
print
'Serving %s on %s:%s'
%
(
filename
,
options
.
interface
,
options
.
port
)
print
'Serving %s on %s:%s'
%
(
filename
,
options
.
interface
,
options
.
port
)
server
.
serve_forever
()
server
.
serve_forever
()
else
:
else
:
sys
.
stderr
.
write
(
"USAGE: %s /path/to/app.wsgi
\
n
app.wsgi is a python script defining 'application' callable
\
n
"
%
sys
.
argv
[
0
])
sys
.
stderr
.
write
(
parser
.
format_help
())
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment