Skip to content

Commit 0953bc8

Browse files
committed
Add next_slot_available convenience method
1 parent 7804c87 commit 0953bc8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

overpass/api.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# See LICENSE.txt for the full license text.
55

66
import csv
7+
from typing import Union
78
import json
89
import logging
910
import re
@@ -200,6 +201,15 @@ def slots_running(self) -> tuple:
200201
"""
201202
return self._api_status()["running_slots"]
202203

204+
@property
205+
def next_slot_available(self) -> Union(None, datetime):
206+
"""
207+
:returns: None if a slot is available now, or a datetime for when the next slot is free
208+
"""
209+
if self.slots_available:
210+
return None
211+
return min(self.slots_running + self.slots_waiting)
212+
203213
def search(self, feature_type, regex=False):
204214
"""Search for something."""
205215
raise NotImplementedError()

0 commit comments

Comments
 (0)