Notification Deadlock problem, "send alert on" : "custom" method

first of all, can help me somebody with Notification doctype?
Here is an option “custom” in “send alert on” menu, how does it work please?
Ideally, I need call specific notification exactly from the server side script.

Now I have workaround on the Task dct:

We send the email notifications 15 minutes after “start ETA” if here is wrong workflow_state status.
If the condition is TRUE then server script set the custom field (checkbox) on Task dct to TRUE state and save the doc.
The notification is set to “value change” in “send alert on” and the custom field is watched.
If it is in TRUE state the notification is send and “Set property after alert” set the custom field to FALSE state.

In ca. 20% here is a problem with “deadlock problem” and the notification is not send. It is look like here is a conflict between “Set property after alert” method and inserting communication to the task:

 raise frappe.QueryDeadlockError(e) from e
      self = <frappe.database.mariadb.database.MariaDBDatabase object at 0x7f88cffc6410>
      query = 'INSERT INTO `tabCommunication` 

Thanks for any tip in advance.
Jirka Š.