Skip to content

Improve documentation on fibers #830

Closed
@lenkis

Description

@lenkis

(1) about fiber.testcancel()

Sergey Й, [16 Jul 2019 at 17:18:33]:
fiber.testcancel() - это магическая функция? Ее exception нельзя перехватить?

tarantool> cleanup_ok = false
---
...

tarantool> f = fiber.create(function() while pcall(fiber.testcancel) do fiber.sleep(1)  end cleanup_ok = true end)
---
...

tarantool> f
---
- status: suspended
  name: lua
  id: 120
...

tarantool> f:cancel()
---
...

tarantool>
---
...

tarantool> f
---
- the fiber is dead
...

tarantool> cleanup_ok
---
- false
...

для сравнения

tarantool> err = false f = fiber.create(function() while pcall(function() if err then error() end end) do fiber.sleep(1) end print("\n\ncleanup ok !!!!!!!!!!!!!") end)
---
...

tarantool> err = true
---
...

tarantool>

cleanup ok !!!!!!!!!!!!!

---
...

Где-нибудь в доках есть объяснение?

(2) about fiber_object.cancel()

Sergey Й, [16 Jul 2019 at 17:28:34]:
еще по докам

tarantool> f = fiber.create(fiber.sleep, 999)
---
...

tarantool> f
---
- status: suspended
  name: lua
  id: 145
...

tarantool> f:cancel()
---
...

tarantool> f
---
- the fiber is dead
...

tarantool> f:id()
---
- 145
...

tarantool> box.info.version
---
- 1.10.2-0-gc0d8063b6
...

https://www.tarantool.io/en/doc/1.10/reference/reference_lua/fiber/#lua-function.fiber_object.cancel

After a fiber has been cancelled, attempts to operate on it will cause errors, for example fiber_object:id() will cause error: the fiber is dead.

No, the real behavior is different!

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingneed feedback[special status] On hold, awaiting feedbackreference[location] Tarantool manual, Reference partserver[area] Task relates to Tarantool's server (core) functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions