neumond / python-computer-craft

Pythonization of ComputerCraft Minecraft mod. Write Python instead Lua!
MIT License
69 stars 7 forks source link

Supporting Development #7

Closed apockill closed 3 years ago

apockill commented 3 years ago

I picked this library up a month ago and have been using it to great extent for an extensive turtle control framework. It's been quite fun!

I love the library, and I would love to support it. Are there any tasks that need doing, or ways I can donate?

neumond commented 3 years ago

I'm glad you've found my work helpful! Unfortunately, currently I'm quite busy on job and with personal issues, I can't spare enough time on my github. Therefore, asking for donations would be kinda unhonest, since I can't promise to do more than I already have to do.

But contributions are welcome, if you see anything that can be improved, I'm open for discussions and for PRs solving existing issues (currently it's websocket problem and compatibility with older minecraft/mod). Two more general issues I see are security and hanging prevention.

Regarding security, python can't eval/exec isolated sandboxes, Victor Stinner has made some work in that way, though unsuccessful https://github.com/vstinner/pysandbox, he recommends to run python in external sandbox rather than to implement sandbox inside python. This would mean we have to run a separate OS process for each CC:T computer. Making it secure may also close the door to external libraries available from pypi, here I'm not sure what is better, probably just providing some configuration to the user. Another thing is authorization against MC server to allow incoming connections only from specific game.

On hanging prevention, we need some sort of OS timer, that will stop infinite program execution after some timeout. I was thinking about using SIGALRM, but that's not cross-platform approach. Probably multithreading/processing may also help to sustain more load/long actively computing programs, but I'm not sure which approach to scaling is better: we may even run pool of single threaded python servers and choose randomly among them right in lua script. Same for memory, it's good to have some memory limit for an in-game program.

Probably additional thing to do is testing and keeping the library up to date with current state of CC:T.

apockill commented 3 years ago

Thank you for the overview! I might be able to handle the multi-threading/processing changes.

Here's what I think I'll do- I'm going to keep working on my side project, which is basically just a robust stateless framework for running turtles that is safe during restarts or chunk unloading. Once I scale up my projects to 10, 20, 50 turtles, I might encounter more bugs or pain points in the library. I'll make some issues as I come across them and make some PR's.

So far so good though!