Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Chris
Pixelframe
Commits
d8892c4f
Commit
d8892c4f
authored
Dec 22, 2020
by
Christian Wander
Browse files
making naive threading work
parent
da9ea048
Changes
2
Hide whitespace changes
Inline
Side-by-side
pixelframe/controllers.py
View file @
d8892c4f
from
pixelframe
import
app
from
flask
import
render_template
import
pixelframe.threadfun
as
t
@
app
.
route
(
'/'
)
def
main_page
():
...
...
@@ -10,3 +11,8 @@ def main_page():
@
app
.
route
(
'/hello'
)
def
hello_method
():
return
render_template
(
'hello.html'
,
name
=
"foo"
)
@
app
.
route
(
'/threadfun'
)
def
threadfun
():
t
.
doit
()
return
"Started work."
pixelframe/threadfun.py
0 → 100644
View file @
d8892c4f
import
threading
import
time
def
doit
():
print
(
f
'>> Starting a thread ...'
)
x
=
threading
.
Thread
(
target
=
threaded_function
)
x
.
start
()
print
(
f
'>> Thread started.'
)
def
threaded_function
():
print
(
f
'>> Doing some work within thread ...'
)
time
.
sleep
(
2
)
print
(
f
'>> Finished work within thread!'
)
Write
Preview
Supports
Markdown
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