How to get to know when qtconcurrent actually run - qtconcurrent

As mentioned in doc for QtConcurrent::run:
Note that the function may not run immediately; the function will only be run when a thread is available.
So here is a question: how to handle job running?
QFutureWatcher signal start is not suitable because
This signal is emitted when this QFutureWatcher starts watching the future set with setFuture().

Related

Exception handling with Realbrowserlocusts

In using realbrowserlocusts class it appears that I'm limited in any exception handling.
The only reference that partially works is: self.client.wait.until(EC.visibility_of_element_located ....
In a failed condition where the element is not found the script simply starts over again. With the script I'm working with I need to maintain a solid session state; I need to throw and exception(report an error), log the user out and then let the script start over again. I've been testing out the behavior with the locust.py script that Nick B. created with several approaches to "try, except" and they work running without realbrowserlocusts (selenium only) but with it the execution just stops.
Any examples would be greatly appreciated.
In its current format I've been able to run 3x the amount of a browser-based load per/agent/slave than our commercial tool. My goal is to replace it with a locust/selenium approach.
locust-plugins's WebdriverUser has a little bit better exception handling I think. A failure to find an element will log a failed request and if you use RescheduleTaskOnFail (as in the the example) it will restart the task when that happens.
https://github.com/SvenskaSpel/locust-plugins/blob/master/examples/webdriver_ex.py

How does thread::join run a script?

I see where thread::create creates a thread and thread::send sends a script to it. But thread::join has no script argument. thread::join is presented in the manual as if it is a alternate for thread::send, but I can't see how to send scripts to a thread if it's joinable.
I see it blocks, which an be useful for some apps, but I don't see the value statement in thread::join yet, please give an example of how thread::join can run scripts in a separate thread. Or better explain it's value in a way the manual does not make clear to me.
I do not know where you got the idea that thread::join runs a script; it doesn't. What it actually does is send a (C API level) message to the other thread to ask it to terminate gracefully and then waits for the thread to actually terminate; the thread::wait command knows how to handle such messages correctly, but most of that is just “run the event loop and watch in case a terminate message comes in” (which is why that command is supposed to always be used as the last one of a thread's body script if it is supposed to become responsive to events).
The actual joinability is about handling the reverse message signalling that a thread has really terminated.

Google Cloud Function: lazy loading not working

I deploy a google cloud function with lazy loading that loads data from google datastore. The last update time of my function is 7/25/18, 11:35 PM. It works well last week.
Normally, if the function is called less than about 30 minutes since last called. The function does not need to load data loaded from google datastore again. But I found that the lazy loading is not working since yesterday. Even the time between two function is less than 1 minute.
Does anyone meet the same problem? Thanks!
The Cloud Functions can fail due to several reasons such as uncaught exception and internal process crashes, therefore, it is required to check the logs files / HTTP responses error messages to verify the issue root cause and determine if the function is being restarted and generating Function execution timeouts that could explain why your function is not working.
I suggest you take a look on the Reporting Errors documentation that explains the process required to return a function error in order to validate the exact error message thrown by the service and return the error at the recommended way. Keep in mind that when the errors are returned correctly, then the function instance that returned the error is labelled as behaving normally, avoiding cold starts that leads higher latency issues, and making the function available to serve future requests if need be.

How do i make the game wait until a funcion is called?

I was creating a script and i want to know how do i make the game wait until a funcion is called
If someone awnser me,ill be thankful
Firstly do not use loops, use events!
To wait for an event to happen you can use the wait method, like so:
print("Starting to wait for touch")
workspace.Part.Touched:Wait()
print("Touched!")
This will wait for the part to be touched before it continues the script.
But ofcourse, other scripts will still run, the game is not "paused", it is just that script's execution that is suspended until the event is fired.
You can also make custom "wait for call" by using for example a BoolValue like so:
local WaitObject = Instance.new("BoolValue")
function WaitOn()
WaitObject.Changed:Wait()
end
function StopWait()
WaitObject.Value = not WaitObject.Value
end
You can also place the BoolValue in the game and do the wait and stop wait in separated scripts.
If you do it in same script, remember to use different threads

my nodejs script is not exiting on its own after successful execution

I have written a script to update my db table after reading data from db tables and solr. I am using asyn.waterfall module. The problem is that the script is not getting exited after successful completion of all operations. I have used db connection pool also thinking that may be creating the script to wait infinitly.
I want to put this script in crontab and if it will not exit properly it would be creating a hell lot of instances unnecessarily.
I just went through this issue.
The problem with just using process.exit() is that the program I am working on was creating handles, but never destroying them.
It was processing a directory and putting data into orientdb.
so some of the things that I have come to learn is that database connections need to be closed before getting rid of the reference. And that process.exit() does not solve all cases.
When my project processed 2,000 files. It would get down to about 500 left, and the extra handles would have filled up the available working memory. Which means it would not be able to continue. Therefore never reaching the process.exit at the end.
On the other hand, if you close the items that are requesting the app to stay open, you can solve the problem at its source.
The two "Undocumented Functions" that I was able to use, were
process._getActiveHandles();
process._getActiveRequests();
I am not sure what other functions will help with debugging these types of issues, but these ones were amazing.
They return an array, and you can determine a lot about what is going on in your process by using these methods.
You have to tell it when you're done, by calling
process.exit();
More specifically, you'll want to call this in the callback from async.waterfall() (the second argument to that function). At that point, all your asynchronous code has executed, and your script should be ready to exit.
EDIT: As pointed out by #Aaron below, this likely has to do with something like a database connection being active, and not allowing the node process to end.
You can use the node module why-is-node-running:
Run npm install -D why-is-node-running
Add import * as log from 'why-is-node-running'; in your code
When you expect your program to exit, add a log statement:
afterAll(async () => {
await app.close();
log();
})
This will print a list of open handles with a stacktrace to find out where they originated:
There are 5 handle(s) keeping the process running
# Timeout
/home/maf/dev/node_modules/why-is-node-running/example.js:6 - setInterval(function () {}, 1000)
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
# TCPSERVERWRAP
/home/maf/dev/node_modules/why-is-node-running/example.js:7 - server.listen(0)
/home/maf/dev/node_modules/why-is-node-running/example.js:10 - createServer()
We can quit the execution by using:
connection.destroy();
If you use Visual Studio code, you can attach to an already running Node script directly from it.
First, run the Debug: Attached to Node Process command:
When you invoke the command, VS Code will prompt you which Node.js process to attach to:
Your terminal should display this message:
Debugger listening on ws://127.0.0.1:9229/<...>
For help, see: https://nodejs.org/en/docs/inspector
Debugger attached.
Then, inside your debug console, you can use the code from The Lazy Coder’s answer:
process._getActiveHandles();
process._getActiveRequests();