Mercurial Hosting > luan
comparison src/luan/modules/http/tools/Shell.luan @ 1322:d5739c101bd6
improve Thread
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 06 Feb 2019 01:11:12 -0700 |
parents | 590ad449ac7f |
children | 1604d7f36f3a |
comparison
equal
deleted
inserted
replaced
1321:307e76ccd0d6 | 1322:d5739c101bd6 |
---|---|
19 local logger = Logging.logger "Shell" | 19 local logger = Logging.logger "Shell" |
20 | 20 |
21 | 21 |
22 local Shell = {} | 22 local Shell = {} |
23 | 23 |
24 local forever = Time.period{days=1000000} | |
25 local count = 0 | 24 local count = 0 |
26 local new_session = Thread.global_callable("shell.new_session",forever,{next=function() | 25 local new_session = Thread.global_callable("shell.new_session",{next=function() |
27 count = count + 1 | 26 count = count + 1 |
28 return to_string(count) | 27 return to_string(count) |
29 end}).next | 28 end}).next |
30 | 29 |
31 local env = {} | 30 local env = {} |
55 end | 54 end |
56 | 55 |
57 local timeout = Time.period{hours=10} | 56 local timeout = Time.period{hours=10} |
58 | 57 |
59 local function get_session(session_id) | 58 local function get_session(session_id) |
60 return Thread.global_callable("shell.session"..session_id,timeout,fns) | 59 return Thread.global_callable("shell.session"..session_id,fns,timeout) |
61 end | 60 end |
62 | 61 |
63 function Shell.respond() | 62 function Shell.respond() |
64 Io.stdout = Http.response.text_writer() | 63 Io.stdout = Http.response.text_writer() |
65 local cmd = Http.request.parameters.cmd | 64 local cmd = Http.request.parameters.cmd |