Skip to content

Commit

Permalink
Add sleep method to message.py
Browse files Browse the repository at this point in the history
 -This resolves #285 and closes #241
  • Loading branch information
wanmingx.lin committed Oct 15, 2014
1 parent 44ed87e commit 1257b7c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions eventsource/resources/message.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import time

def main(request, response):
mime = request.GET.first("mime", "text/event-stream")
message = request.GET.first("message", "data: data");
newline = "" if request.GET.first("newline", None) == "none" else "\n\n";
sleep = int(request.GET.first("sleep", "0"))

headers = [("Content-Type", mime)]
body = message + newline + "\n"
if sleep != 0:
time.sleep(sleep/1000)

return headers, body

0 comments on commit 1257b7c

Please sign in to comment.