question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

coroutines that return before their first yield cause the simulator to shutdown

See original GitHub issue

Repro:

@cocotb.test()
def test_func_empty(dut):
    """ Test that a function can complete before the first yield """
    @cocotb.coroutine
    def func_empty():
        print("This line runs")
        return
        yield  # needed to make this a coroutine
    yield func_empty()
    print("This line is never reached")

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
marlonjamescommented, May 6, 2020

If I remove all of the clk_gen = cocotb.fork(Clock(dut.clk, 100).start()) lines and run the test_external module on #1705, everything passes.

0reactions
eric-wiesercommented, May 7, 2020

It looks to me like test_ext_exit_error is just nonsense - I’d remove it as part of the cleanup.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Coroutines — cocotb 1.1 documentation
Typically coroutines yield a Trigger object which indicates to the simulator some event which will cause the coroutine to be woken when it...
Read more >
Classic Coroutines | Fluent Python, the lizard book
How coroutines can return values upon termination. Usage and semantics of the new yield from syntax. A use case: coroutines for managing concurrent...
Read more >
Scripting: What resumes when I yield(0) from a coroutine ...
The statement "coroutine.yield(0)" should cause control flow to return to a statement like "return_value = coroutine.resume(coroutine_name)" ...
Read more >
Making sense of generators, coroutines, and "yield from" in ...
That's because Python reaches that first “return” statement and returns 1. ... Because generators (i.e., the objects returned by generator ...
Read more >
Scripting API: MonoBehaviour.StartCoroutine - Unity - Manual
The StartCoroutine method returns upon the first yield return, however you can yield the result, which waits until the coroutine has finished execution....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found