Hello, I want to check if a cloud function is running and wait the end of the execution before to run a new one. How can I achieve that?
Hello. In your code you should get a response by default when you trigger it client sided
Example in Dart (tell me your preferred lang and will write one if needed):
try {
final execution = await functions.createExecution(
functionId: '[FUNCTION_ID]',
body: json.encode({ 'foo': 'bar' }),
async: false,
path: '/',
method: 'GET',
headers: {
'X-Custom-Header': '123'
}
);
//you can trigger here anything since the function executed successfully
print("The function got executed correctly. Response:")
print(execution.toMap());
} catch (e) {
//this will be triggered if the function execution fails or there is a network/appwrite issue
print("An error ocurred:")
print(e.message);
}
thank you for your response, I have multiple clients that access that function. I need to check if the function is running, it should be thread safe.
Note that doesn't goes in the function, but client side code
Could change depending on your appwrite version. The code I sent is for latest appwrite version
I would do it by creating a locks collection.
When the function runs, it'll create a document with a specific id. If it can create the document, it should continue processing and then delete the document when done executing. Any other function that tries to run would get an error because no 2 documents can have the same ID
Recommended threads
- Clean install of 1.9.0 shows errors in a...
I just run a full clean install of Appwrite on my server following the Manual installation guide in the docs page. The console seems to work, visually there d...
- Setup custom domain on selfhosted behind...
Hello everyone, can anyone help me to setup a custom domain on a selfhosted appwrite instance thats running behind cloudflare tunnels? Current setup: Appwrite r...
- Why does this happen?
`AppwriteException: general_argument_invalid, Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars (400)` the...