# My App is slow

## High CPU Usage with tryGet() in a Tight Loop

### The Problem

If you run:

```python
while True:
    queue.tryGet()
```

tryGet() is non-blocking - it returns immediately whether a frame is ready or not. In a tight loop, this means your program spins
as fast as possible, maxing out a CPU core and starving other threads or processes.

### The Fixes

a) Add a Small Sleep

Let the CPU breathe between calls:

```python
#!/usr/bin/env python3
import depthai as dai
import time
with dai.Pipeline() as pipeline:
    cam = pipeline.create(dai.node.Camera).build(
        dai.CameraBoardSocket.CAM_A, sensorFps=19.0
    )
    rawQueue = cam.raw.createOutputQueue()
    pipeline.start()
    while pipeline.isRunning():
        rawFrame = rawQueue.tryGet()
        if rawFrame is not None:
            print("Got a raw frame")
        time.sleep(0.001)  # prevents 100% CPU usage
```

b) Use get() Instead of tryGet()

get() blocks until a frame is ready, so no busy looping:

```python
#!/usr/bin/env python3
import depthai as dai
import time
with dai.Pipeline() as pipeline:
    cam = pipeline.create(dai.node.Camera).build(
        dai.CameraBoardSocket.CAM_A, sensorFps=19.0
    )
    rawQueue = cam.raw.createOutputQueue()
    pipeline.start()
    while pipeline.isRunning():
        rawFrame = rawQueue.get()
        print("Got a raw frame")
```
