Skip to content

Commit 1f0629a

Browse files
committed
#16 Implement customizable timeouts for calls
1 parent 56adcb6 commit 1f0629a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/page_session.ex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ defmodule ChromeRemoteInterface.PageSession do
8585
`:async` -
8686
If a boolean, sends the response as a message to the current process.
8787
Else, if provided with a PID, it will send the response to that process instead.
88+
89+
`:timeout` -
90+
This sets the timeout for the blocking call, defaults to 5 seconds.
8891
"""
8992
def execute_command(pid, method, params, opts) do
9093
async = Keyword.get(opts, :async, false)
94+
timeout = Keyword.get(opts, :timeout, 5_000)
9195

9296
case async do
93-
false -> call(pid, method, params)
97+
false -> call(pid, method, params, timeout)
9498
true -> cast(pid, method, params, self())
9599
from when is_pid(from) -> cast(pid, method, params, from)
96100
end
@@ -99,8 +103,8 @@ defmodule ChromeRemoteInterface.PageSession do
99103
@doc """
100104
Executes a raw JSON RPC command through Websockets.
101105
"""
102-
def call(pid, method, params) do
103-
GenServer.call(pid, {:call_command, method, params})
106+
def call(pid, method, params, timeout) do
107+
GenServer.call(pid, {:call_command, method, params}, timeout)
104108
end
105109

106110
@doc """

0 commit comments

Comments
 (0)