MCPcopy
hub / github.com/scrapy/scrapy / peek

Method peek

scrapy/squeues.py:54–69  ·  view source on GitHub ↗

Returns the next object to be returned by :meth:`pop`, but without removing it from the queue. Raises :exc:`NotImplementedError` if the underlying queue class does not implement a ``peek`` method, which is optional for queues.

(self)

Source from the content-addressed store, hash-verified

52 return None
53
54 def peek(self) -> Any | None:
55 """Returns the next object to be returned by :meth:`pop`,
56 but without removing it from the queue.
57
58 Raises :exc:`NotImplementedError` if the underlying queue class does
59 not implement a ``peek`` method, which is optional for queues.
60 """
61 try:
62 s = super().peek()
63 except AttributeError as ex:
64 raise NotImplementedError(
65 "The underlying queue class does not implement 'peek'"
66 ) from ex
67 if s:
68 return deserialize(s)
69 return None
70
71 return SerializableQueue
72

Callers 7

peekMethod · 0.45
test_one_elementMethod · 0.45
test_orderMethod · 0.45
test_no_peek_raisesMethod · 0.45
test_peekMethod · 0.45
test_no_peek_raisesMethod · 0.45
test_peekMethod · 0.45

Calls

no outgoing calls

Tested by 6

test_one_elementMethod · 0.36
test_orderMethod · 0.36
test_no_peek_raisesMethod · 0.36
test_peekMethod · 0.36
test_no_peek_raisesMethod · 0.36
test_peekMethod · 0.36