need to unregister an close all events (fixes "too many open files" error)

This commit is contained in:
Christian Ulrich 2020-10-06 10:04:21 +02:00
parent 5a30d6e015
commit b5406aa83b
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 4 additions and 0 deletions

View File

@ -40,12 +40,16 @@ proc asyncExecCmd*(command: string): Future[string] =
proc successCallback(fd: AsyncFD): bool =
future.complete(^flowVar)
successEvent.unregister()
successEvent.close()
failureEvent.unregister()
failureEvent.close()
true
proc failureCallback(fd: AsyncFD): bool =
future.fail(newException(OSError, ^flowVar))
successEvent.unregister()
successEvent.close()
failureEvent.unregister()
failureEvent.close()
true
addEvent(successEvent, successCallback)
addEvent(failureEvent, failureCallback)