краш copas

Tema05

Известный
Автор темы
1,515
481
Версия MoonLoader
.026-beta
Юзаю socket + copas по примеру FYP'а вот от сюда https://www.blast.hk/threads/20532/
Периодически возникает вот такой краш:
sa-mp-011.png

Из-за чего может такое быть и как это исправить?
Ниже прикрепил файл библиотеки.
Lua:
function httpRequest(request, body, handler) -- copas.http
    -- start polling task
    if not copas.running then
        copas.running = true
        lua_thread.create(function() --2096
            wait(0)
            while not copas.finished() do
                local ok, err = copas.step(0) --2099
                if ok == nil then error(err) end
                wait(0)
            end
            copas.running = false
        end)
    end
    -- do request
    if handler then
        return copas.addthread(function(r, b, h)
            copas.setErrorHandler(function(err) h(nil, err) end)
            h(http.request(r, b))
        end, request, body, handler)
    else
        local results
        local thread = copas.addthread(function(r, b)
            copas.setErrorHandler(function(err) results = {nil, err} end)
            results = table.pack(http.request(r, b))
        end, request, body)
        while coroutine.status(thread) ~= 'dead' do wait(0) end
        return table.unpack(results)
    end
end
 

Вложения

  • copas.lua
    27.9 KB · Просмотры: 179
Последнее редактирование: