]> git.lizzy.rs Git - lua_async.git/commitdiff
Fix optional socket dependency
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 28 Nov 2021 19:55:33 +0000 (20:55 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sun, 28 Nov 2021 19:55:33 +0000 (20:55 +0100)
init.lua

index 368ffa9d5293f865f64344f73223f28bde9a2c79..b5cb92e17f932a15376d939aad213b2fa186574a 100644 (file)
--- a/init.lua
+++ b/init.lua
@@ -1,9 +1,5 @@
 lua_async = {}
 
-if rawget(_G, "require") then
-       lua_async.socket = require("socket")
-end
-
 function lua_async.clock()
        return lua_async.socket and lua_async.socket.gettime() or os.clock()
 end
@@ -25,7 +21,11 @@ function lua_async.step(dtime)
        -- close phase is obsolete
 end
 
-return function(path)
+return function(path, no_socket)
+       if not no_socket then
+               lua_async.socket = require("socket")
+       end
+
        for _, f in ipairs {
                "timeouts",
                "intervals",