Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time.sleep() using Wasmer #4671

Closed
nunolima41 opened this issue May 11, 2024 · 1 comment · Fixed by #4682
Closed

time.sleep() using Wasmer #4671

nunolima41 opened this issue May 11, 2024 · 1 comment · Fixed by #4682
Assignees
Labels
priority-high High priority issue
Milestone

Comments

@nunolima41
Copy link

Describe the bug

When compiling a Python script that uses the time.sleep() function to WebAssembly using py2wasm, the execution of the WebAssembly module stops when using the Wasmer Runtime. Other runtimes, it works, so I believe it's a wasmer specific issue.

This problem was already discussed in a Discord thread in the official Wasmer server, (https://discord.com/channels/1110300506942881873/1235299336401850518)

Steps to reproduce

I succesfully compiled this Python script using py2wasm.

import time

def fibonacci(n):
    fib_sequence = []
    a, b = 0, 1
    while len(fib_sequence) < n:
        fib_sequence.append(a)
        a, b = b, a + b
    return fib_sequence


def print_fibonacci(n):
    for num in fibonacci(n):
        print(num)
        time.sleep(2)

# Change the value of 'terms' to adjust the number of Fibonacci numbers printed
terms = 15
print_fibonacci(terms)

However, when i run this ('wasmer run Fibonacci.wasm'), the output it 0 and it stops. When i comment "time.sleep(2)", it prints the result correctly.

Expected behavior

The application should not stop after calling time.sleep.

@maminrayej maminrayej self-assigned this May 13, 2024
@maminrayej
Copy link
Contributor

This issue also happens when running the following command:

wasmer run python/python -- -c "import time; print('start'); time.sleep(1); print('end')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority-high High priority issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants