Discussion:
[bottlepy] threading
Klieber frederic
2015-12-02 20:54:56 UTC
Permalink
With this code :

import threading
from bottle import route, run, template

@route('/hello/<name>')
def index(name):
return "coucou"
server_thread =threading.Thread(target=run(host='localhost', port=8080))
server_thread.start()
print "continue ... "



The line "continue ..." is never printed

Any idea ? Do i miss something ?

Thanks for your reply
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Klieber frederic
2015-12-02 20:48:02 UTC
Permalink
I need to run this code :

import threading
from bottle import route, run, template

@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)
server_thread =threading.Thread(target=run(host='localhost', port=8080))
server_thread.start()
print "continue ... "



The server is running, but "continue ..." is never printed.

Do I miss something ? Any idea ?

Thanks for your reply
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ron Rothman
2015-12-03 14:03:02 UTC
Permalink
You're using Thread incorrectly. The "target" argument should be a
reference to a function, but you are actually *calling* your function,
"run", and passing its result to Thread. You may want to read this:
https://docs.python.org/2/library/threading.html#threading.Thread
Post by Klieber frederic
import threading
from bottle import route, run, template
@route('/hello/<name>')
return template('<b>Hello {{name}}</b>!', name=name)
server_thread =threading.Thread(target=run(host='localhost', port=8080))
server_thread.start()
print "continue ... "
The server is running, but "continue ..." is never printed.
Do I miss something ? Any idea ?
Thanks for your reply
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.
---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an
For more options, visit https://groups.google.com/d/optout.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ron Rothman
2015-12-03 14:05:39 UTC
Permalink
You're using Thread incorrectly. The "target" argument should be a
reference to a function, but you are actually *calling* your function,
"run", and then passing the *result* to Thread. You may want to read this:
https://docs.python.org/2/library/threading.html#threading.Thread
Post by Klieber frederic
import threading
from bottle import route, run, template
@route('/hello/<name>')
return "coucou"
server_thread =threading.Thread(target=run(host='localhost', port=8080))
server_thread.start()
print "continue ... "
The line "continue ..." is never printed
Any idea ? Do i miss something ?
Thanks for your reply
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Klieber frederic
2015-12-03 14:47:13 UTC
Permalink
Ron, you're absolutly right ! Thank you
The code who works is :

import threading
from bottle import route, run, template

def run_func():
run(host='localhost', port=8000)

@route('/hello/<name>')
def index(name):
return template('<b>Hello {{name}}</b>!', name=name)

server_thread =threading.Thread(target=run_func)
server_thread.start()


print "continue ... "
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Klieber frederic
2015-12-03 16:49:33 UTC
Permalink
OK, I've just realised that if my program works, stopping completely the
server launched by Bottle will not be so easy ...
I' ve a working solution inspired from this :

http://stackoverflow.com/questions/11282218/bottle-web-framework-how-to-stop

But it seems that Bottle has no clear function to stop everything.
The post is 2 years old, has anybody a cleaner-better solution ?
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...