{"action":"created","issue":{"url":"https://api.github.com/repos/domoticz/domoticz/issues/1633","repository_url":"https://api.github.com/repos/domoticz/domoticz","labels_url":"https://api.github.com/repos/domoticz/domoticz/issues/1633/labels{/name}","comments_url":"https://api.github.com/repos/domoticz/domoticz/issues/1633/comments","events_url":"https://api.github.com/repos/domoticz/domoticz/issues/1633/events","html_url":"https://github.com/domoticz/domoticz/pull/1633","id":236841765,"number":1633,"title":"EventSystem make threaded / match Lua and Python file name on devicename ","user":{"login":"jvandenbroek","id":3118327,"avatar_url":"https://avatars3.githubusercontent.com/u/3118327?v=3","gravatar_id":"","url":"https://api.github.com/users/jvandenbroek","html_url":"https://github.com/jvandenbroek","followers_url":"https://api.github.com/users/jvandenbroek/followers","following_url":"https://api.github.com/users/jvandenbroek/following{/other_user}","gists_url":"https://api.github.com/users/jvandenbroek/gists{/gist_id}","starred_url":"https://api.github.com/users/jvandenbroek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvandenbroek/subscriptions","organizations_url":"https://api.github.com/users/jvandenbroek/orgs","repos_url":"https://api.github.com/users/jvandenbroek/repos","events_url":"https://api.github.com/users/jvandenbroek/events{/privacy}","received_events_url":"https://api.github.com/users/jvandenbroek/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-06-19T10:10:42Z","updated_at":"2017-06-20T10:16:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/domoticz/domoticz/pulls/1633","html_url":"https://github.com/domoticz/domoticz/pull/1633","diff_url":"https://github.com/domoticz/domoticz/pull/1633.diff","patch_url":"https://github.com/domoticz/domoticz/pull/1633.patch"},"body":"- Threading the EvaluateEvent function prevents Domoticz to stall on Lua / Blockly / Python processing, makes multi-core processing very efficient. \r\n\r\n- Matching device name on file name. E.g. script_device_devicename.lua (or .py for Python) will only be executed when DeviceName is processed (case insensitive, DeviceName is lower cased and spaces are replaced with underscores). On the other hand script_device_somenamethatdoesntexist.lua will just be matched on ALL devices, just as the current behavior. The logic inside the scripts (devicechanged / otherdevices etc) hasn't changed. Executing Lua is a costly process, so this saves a lot (system load reduced considerably).\r\n\r\n- Added AddVariable for Lua, which allows to do something like this in your scripts:\r\n```\r\nlocal variable = uservariables['SomeVariable']\r\nif (variable == nil) then\r\ncommandArray['AddVariable:SomeVariable'] = tostring(\"Float:12.12\")}\r\nelse\r\ncommandArray['Variable:SomeVariable'] = tostring(\"12.12\")}\r\nend\r\n```\r\n\r\nBy implementing the threaded / file match concept with unique_lock / shared_lock mutexes, multiple scripts can run fast simultaneously when reading, without the risk of lockups/races. Timing has become much more predictable now. On my RPi 1, all my switches now respond almost instantaneously, despite the fairly high number of Lua scripts I have. I can only imagine the latency reduction on multi-core systems ;)"},"comment":{"url":"https://api.github.com/repos/domoticz/domoticz/issues/comments/309709533","html_url":"https://github.com/domoticz/domoticz/pull/1633#issuecomment-309709533","issue_url":"https://api.github.com/repos/domoticz/domoticz/issues/1633","id":309709533,"user":{"login":"dnpwwo","id":6850332,"avatar_url":"https://avatars3.githubusercontent.com/u/6850332?v=3","gravatar_id":"","url":"https://api.github.com/users/dnpwwo","html_url":"https://github.com/dnpwwo","followers_url":"https://api.github.com/users/dnpwwo/followers","following_url":"https://api.github.com/users/dnpwwo/following{/other_user}","gists_url":"https://api.github.com/users/dnpwwo/gists{/gist_id}","starred_url":"https://api.github.com/users/dnpwwo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnpwwo/subscriptions","organizations_url":"https://api.github.com/users/dnpwwo/orgs","repos_url":"https://api.github.com/users/dnpwwo/repos","events_url":"https://api.github.com/users/dnpwwo/events{/privacy}","received_events_url":"https://api.github.com/users/dnpwwo/received_events","type":"User","site_admin":false},"created_at":"2017-06-20T10:16:25Z","updated_at":"2017-06-20T10:16:25Z","body":"Sounds like a great idea !\n\nOn 20 June 2017 at 19:34, Joost van den Broek <notifications@github.com>\nwrote:\n\n> I've restored the Python logic, so it will be executed in the same thread\n> as it does now, with the same mutex (unique_lock uservariables) set. Now we\n> know for sure this won't introduce any new issues regarding Python, since\n> there are some problems right now with segfaults etc, let's first make sure\n> that Python runs without issues before (eventually) make it threaded.\n>\n> —\n> You are receiving this because you were mentioned.\n> Reply to this email directly, view it on GitHub\n> <https://github.com/domoticz/domoticz/pull/1633#issuecomment-309699232>,\n> or mute the thread\n> <https://github.com/notifications/unsubscribe-auth/AGiHHBcf0CIno4jWfv1gWzWCtJbSfZbMks5sF5IRgaJpZM4N-BK6>\n> .\n>\n"}}
{"actor":{"display_login":"dnpwwo"}}