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.

This is further to the discussions in #meta and the 2019 Hacktoberfest channel, and https://github.com/python-discord/site/issues/210

It would be excellent if Snekbox supported a kind of “session mode”. Such a mode would allow one to run a persistent Python process in order to serve up a Python REPL or other long-running interactive application. There are some hang-ups to this approach, however…

Shared Processes

Having Python processes that are shared between multiple sessions is probably not possible for a code-based REPL, as it’s pretty easy to escape the code session and mess with the process or other sessions running in the process.

This means that running a process per-REPL with some kind of time limit or max process limit or something is probably the best approach, but this could get heavy on resources if we’re not careful

lemon suggested looking at PEP 0554 on Discord, which could be very useful for an eventual implementation when it comes to shared processes.

Worker Routing

The current design of Snekbox makes routing to specific workers impossible, and they don’t have a mechanism of communicating with each other in order to route to the correct Python process. Additionally, Gunicorn does not have any way to route requests to specific workers - it’s a fundamental part of how Gunicorn works that prevents us from doing this.

That said, there are a few approaches I think we could take.

  1. A separate daemon could be run that supports asynchronous access and dispatches to persistent processes running under nsjail as required
  2. Falcon could be dropped and replaced with something that is designed with asynchronous programming in mind and is intended to be run as a single worker
  3. REPL scope could be serialised and stored in the database somehow, and reloaded on each request - but this could make operations very slow indeed

I’m entirely unsure what the best approach to this would be, however. The nature of webapps means that you usually distribute load between workers in order to keep things fast, but doing that means you lose a way to route to the same worker for any set of requests.

Does anyone have any comments on this?

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
lemonsauruscommented, Oct 1, 2019

good write-up. I’ll get in touch with them.

0reactions
MarkKozcommented, Apr 9, 2021

This hasn’t gone anywhere, and I don’t feel it’s the direction the eval feature on the bot, let alone snekbox, should go in anyway.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Session-State Modes | Microsoft Learn
InProc mode, which stores session state in memory on the Web server. · StateServer mode, which stores session state in a separate process...
Read more >
Session State in ASP.Net - C# Corner
This is the default session mode in ASP.Net. It stores the information in a memory object in the current application domain. So it...
Read more >
what are different types of sessions in ASP.NET - Stack Overflow
Each option is identified as a session-state mode type. There are four mode types or just modes. In-Process mode, State Server mode, SQL...
Read more >
Session mode >? : r/rocksmith - Reddit
Session mode >? · Take lessons. They'll help you with improving your technique. · Use riff repeater. Bump up the difficulty and slow...
Read more >
session-mode - TechLibrary - Juniper Networks
Configure BFD session mode to be single-hop or multihop. By default, BGP uses single-hop BFD sessions if the peer is directly connected to...
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