The try except block should just surround the import statement. 
The import statement should be located within the check method so that the agent wouldn't crash in case the module is missing.

So for example at the beginning of the check method, you should do:
```python
try:
    import gearman
except ImportError:
    raise Exception("gearman module is missing, please install it by doing blablabla")
```