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

Using Flask with sagemath #35051

Closed
2 tasks done
Eloitor opened this issue Feb 9, 2023 · 3 comments
Closed
2 tasks done

Using Flask with sagemath #35051

Eloitor opened this issue Feb 9, 2023 · 3 comments

Comments

@Eloitor
Copy link
Contributor

Eloitor commented Feb 9, 2023

Is there an existing issue for this?

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.

Did you read the documentation and troubleshoot guide?

  • I have read the documentation and troubleshoot guide

Environment

- **OS**: Void Linux x86_64-glibc
- **Sage Version**: version 9.7, Release Date: 2022-09-19

Steps To Reproduce

  1. Install Flask
  2. Create this example file
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    F = NumberField(x**2-x-1, name='w')
    w = F.gen()
    I = Ideal(F, 1)
    print(F)        # This is fine
    print(I)        # This gives an error
    
    return F.__str__()

if __name__ == '__main__':
    app.run()
  1. run this file with sagemath, and access http://127.0.0.1:5000/ on a browser

Expected Behavior

The field and the ideal are printed in the terminal. The field is shown in the browser.

Actual Behavior

The field is printed in the terminal, but then an error occurs.

This is the output of sage test_flask.sage &> output.txt:

output.txt

Additional Information

No response

@Eloitor Eloitor added the t: bug label Feb 9, 2023
@mezzarobba
Copy link
Member

mezzarobba commented Feb 10, 2023

It works if you change the last line to app.run(threaded=False).

After talking to @videlec who discussed the issue with Bill Alombert before, my understanding is that we are still far from being able to use pari from multiple threads in sage. (See also sagemath/cypari2#116.)

@Eloitor
Copy link
Contributor Author

Eloitor commented Feb 10, 2023

Thanks for the hint! The line should be changed to app.run(threaded=False). Should I close this issue?

@mezzarobba
Copy link
Member

Thanks for the hint! The line should be changed to app.run(threaded=False).

Yes, thanks.

Should I close this issue?

I don't think it makes sense to keep it open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants