To avoid the error
1213: Deadlock found when trying to get lock; try restarting transaction
the best solution is optimizing your database structure, but in some situations the only solution to increase wait timeout. To do it you should set the option called innodb_lock_wait_timeout in your /etc/my.cnf:
innodb_lock_wait_timeout = 600 innodb_rollback_on_timeout
I set innodb_rollback_on_timeout option to rollback the full transaction except last SQL query.

I’m not sure increasing wait timeout will help you in a deadlock situation. In fact there is nothing to do except optimizing the database structure using the “SHOW INNODB STATUS” command.