lev.own

lev

own(resource) -> resource

Register a resource for auto-close when the current task completes

Registers resource for automatic cleanup when the current coroutine finishes (success or error). The resource must have a close() method. Returns the resource for chaining: local sock = lev.own(lev.connect(...)). No-op outside lev.run() or from non-spawned coroutines.

The loop calls close() itself once the task has ended, outside any task. A wait in it raises lev: wait outside a task.