Maintaining focus on a single task until completing it might require a lot of effort, to me. While I'm a talkative person and enjoy long conversations myself, I still can't work/study and talk at the same time.
Usually, I avoid this situation by wearing noise-canceling headphones and most people will just get it. However, one of my coworkers is also the type that enjoys talking for hours and she's unfazed by my cues. She will often interrupt me to make small talk. If I mention I'm trying to focus on a task that requires my full attention, she seems to understand for a few minutes, but then come back with a work-related topic that she manages to extend into a long conversation.
I have also tried explaining that I use headphones because I can't work and talk at the same time, and that I prefer to keep work-related topics in written form, so we can search it later if we need to. Yet, she'll still find other ways: asking if I "also heard someone knocking on the door"; asking for help moving stuff around (she's recovering from a hand injury); asking for help with tech or English terminology; even getting me coffee so I'd have to say if I wanted sugar on it.
Bear in mind she's a really nice person, and she'll act similarly with other people around. Of course, when there's someone else at the office, they soak up her attention and I don't get interrupted as often. Our managers are aware of her behavior and they don't mind, so I have no intention to make a formal complaint.
How can I keep these conversations to a minimum? Even if she needs my help, I'd rather be messaged first (we have corporate instant messaging at our disposal, but they're not enforced) and attend her when I'm ready instead of being interrupted, unless it's an actual emergency.
I want to avoid being blunt with her if possible, but I'm running out of ideas of how to make it work.