3 ms·
The very idea of checking a json every second is a problematic one. But if you need to do it once a second, does it really matter that you could do it in 1ms or
by gostsamo 2y ago
The very idea of checking a json every second is a problematic one. But if you need to do it once a second, does it really matter that you could do it in 1ms or 10ms? And if latency is that important, why don't put a bit more effort for better design instead of spawning a new process every time for something that could be in the main code? This looks to me like a bad design where the tools take the blame.
In regard to the choice of language, Python is not the best tool for most jobs, but it is a tool that always let's you do the job. If you've found a better tool for a certain job, good for you, enjoy it. Python always will be there when you need the next job just done.
- rollcat 2y agoIn this case, the best tool for the job is the one that will let you: 1. Continue to easily iterate on the solution now and in the future (compiled languages have a built-in hinderance, in that you never know when a given binary corresponds to some state of the source tree) 2. Allow you to trivially talk to inotify/ReadDirectoryChangesW /FSEvents/kqueue/etc so that you only need to read the file when it actually changes 3. Minimise maintenance (installing third-party headers/libraries, setting up a project, etc etc) I think the answer here is the shell, fswatch, and jq. https://github.com/emcrisostomo/fswatch https://github.com/emcrisostomo/fswatch https://github.com/jqlang/jq https://github.com/jqlang/jq http://man.openbsd.org/sh http://man.openbsd.org/sh
- faangguyindia 2y agoWith LLMs. Writing c++ or c code of equivalent python code is wayyy too easy. I can write code in any language even the ones I don't know. Just fine the constraints I'll meet the goals 100%.
- sshine 2y ago> <Every chatbot> can make mistakes. Please double-check responses. (~ at the bottom of every commercial LLM app) You can write C/C++ using a chatbot if you could without. If you couldn't without, how would you find the subtle errors that they all produce?
- aeonik 2y agoThe answer is obviously customers call and complain or even cancel contacts!
- anonzzzies 2y agoOr a large class action suit for all the money it lost and info it leaked.
- bitbasher 2y agoAt the very least, I imagine you could improve this a few ways. 1. Spawn a single process/daemonize it. 2. Wake up and check at least once every second (or whatever the preferred timing is). 3. Don't blindly read the JSON every time (check the last modified time before reading the contents). Obviously if it hasn't been modified, then go back to sleep (perhaps shorten the sleep window if time is of the essence). 4. I don't imagine you can guarantee a process finished writing the file before you finish reading the file... so maybe this belongs in a database.